/* GWAN - app shell styles */

:root {
  --bg: #0B0B0B;
  --bg-raised: #141414;
  --bg-input: #161616;
  --border: #262626;
  --text: #F6F1E7;
  --text-dim: #6B6B6B;
  --green: #00A85A;
  --gold: #F2C14E;
  --amber: #E8842B;
  --grey: #6B6B6B;
  --font-display: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: max(0px, env(safe-area-inset-left));
  padding-right: max(0px, env(safe-area-inset-right));
}

a {
  color: var(--gold);
}

button {
  font-family: inherit;
}

/* Wordmark */

.wordmark {
  text-align: center;
  padding: calc(1.75rem + env(safe-area-inset-top)) 1.25rem 0.5rem;
}

.wordmark-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3rem, 14vw, 4.25rem);
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--text);
}

.wordmark-punct {
  color: var(--gold);
}

.wordmark-tagline {
  margin: 0.4rem 0 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* Views */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view[hidden] {
  display: none;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem 1.25rem calc(2rem + env(safe-area-inset-bottom));
  flex: 1;
}

/* Join form */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

input[type="text"],
input[type="tel"] {
  min-height: 56px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font-body);
}

input[type="text"]::placeholder,
input[type="tel"]::placeholder {
  color: var(--text-dim);
}

input[type="text"]:focus,
input[type="tel"]:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}

.agree-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.agree-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-width: 22px;
  margin-top: 2px;
  accent-color: var(--gold);
}

.join-error {
  color: var(--amber);
  font-size: 0.9rem;
  margin: 0;
}

.join-error[hidden] {
  display: none;
}

.btn-gold {
  min-height: 56px;
  background: var(--gold);
  color: #1a1305;
  border: none;
  border-radius: 18px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  padding: 1rem 1.5rem;
  cursor: pointer;
}

.btn-gold:active {
  transform: scale(0.98);
}

.btn-block {
  width: 100%;
}

/* Home view */

.nudges {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(242, 193, 78, 0.12);
  border: 1px solid rgba(242, 193, 78, 0.35);
  border-radius: 16px;
  padding: 0.9rem 1rem;
}

.nudges[hidden] {
  display: none;
}

.nudge-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.nudge-text {
  font-size: 0.9rem;
}

.nudge-call {
  background: var(--gold);
  color: #1a1305;
  border: none;
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-weight: 700;
  min-height: 40px;
  cursor: pointer;
  flex-shrink: 0;
}

.home-header {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.home-hello {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.me-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
}

/* Status grid */

.status-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.status-btn {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.status-btn .icon {
  width: 28px;
  height: 28px;
}

.status-btn:active {
  transform: scale(0.97);
}

.status-btn.active.status-driving,
.status-btn.active.status-free {
  background: var(--green);
  border-color: var(--green);
  color: #04180d;
}

.status-btn.active.status-busy {
  background: var(--amber);
  border-color: var(--amber);
  color: #2a1400;
}

.status-btn.active.status-off {
  background: var(--grey);
  border-color: var(--grey);
  color: #111111;
}

.status-line {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  min-height: 1.2em;
  margin: -0.5rem 0 0;
}

/* Auto-drive */

.autodrive-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
  cursor: pointer;
}

.autodrive-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 27px;
  border-radius: 999px;
  background: #2a2a2a;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.autodrive-row input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.autodrive-row input[type="checkbox"]:checked {
  background: var(--green);
}

.autodrive-row input[type="checkbox"]:checked::before {
  transform: translateX(19px);
}

.autodrive-note {
  margin: -0.75rem 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Crew */

.crew-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.crew-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.crew-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.invite-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}

.invite-btn .icon {
  width: 16px;
  height: 16px;
}

.crew-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.crew-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-raised);
  border-radius: 16px;
  padding: 0.75rem 0.9rem;
  min-height: 64px;
}

.crew-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--grey);
  flex-shrink: 0;
}

.crew-dot.driving,
.crew-dot.free {
  background: var(--green);
}

.crew-dot.busy {
  background: var(--amber);
}

.crew-dot.off {
  background: var(--grey);
}

.crew-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.crew-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crew-line {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.crew-gwan {
  flex-shrink: 0;
  background: var(--gold);
  color: #1a1305;
  font-family: var(--font-display);
  font-weight: 800;
  border: none;
  border-radius: 12px;
  padding: 0.6rem 1rem;
  min-height: 44px;
  cursor: pointer;
}

.crew-gwan.muted {
  background: #2a2a2a;
  color: var(--text-dim);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 1rem;
  margin-top: 0.25rem;
  cursor: pointer;
  min-height: 44px;
}

.logout-btn .icon {
  width: 18px;
  height: 18px;
}

/* Action sheet */

.sheet[hidden] {
  display: none;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg-raised);
  border-radius: 24px 24px 0 0;
  padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: sheet-up 0.2s ease-out;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.sheet-title {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  text-align: center;
}

.sheet-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.05rem;
  background: #1d1d1d;
  border-radius: 14px;
  padding: 1rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  min-height: 56px;
}

.sheet-link .icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  color: var(--gold, #F2C14E);
}

.sheet-cancel {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 1rem;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 0.25rem;
  min-height: 44px;
}

/* Toast */

.toast[hidden] {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #1d1d1d;
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-width: calc(100vw - 2.5rem);
  text-align: center;
}

/* Legal page reuses these base rules plus its own in legal/index.html inline block */

.legal {
  padding: 1.5rem 1.25rem calc(2.5rem + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.55;
}

.legal h1 {
  font-family: var(--font-display);
  font-weight: 800;
}

.legal h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  margin-top: 2rem;
}

.legal a {
  color: var(--gold);
}

.legal .back-link {
  display: inline-block;
  margin-top: 2rem;
  color: var(--text-dim);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
