/* Hemfärd — Swedish road-sign vernacular: plates with an inset keyline,
   sign yellow for "ready", sign blue for the one action. */

@font-face {
  font-family: 'Overpass';
  src: url('/fonts/overpass.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ground: #E7E9E5;      /* concrete */
  --plate: #F7F8F5;
  --ink: #1A1C1E;
  --ink-soft: #565C62;
  --rule: #C5C9C4;
  --yellow: #F5C400;      /* sign yellow; text on it is always --on-yellow */
  --on-yellow: #1A1C1E;
  --blue: #0A58A8;        /* sign blue */
  --blue-press: #084A8E;
  --on-blue: #FFFFFF;
  --online: #1E8C4E;
  --danger: #B3261E;
  --radius: 10px;
  --gap: clamp(16px, 3vw, 28px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #25282B;    /* asphalt */
    --plate: #2E3236;
    --ink: #ECEDE9;
    --ink-soft: #A2A8AD;
    --rule: #464B50;
    --blue: #1A66B8;
    --blue-press: #0F5AA8;
    --online: #3CC477;
    --danger: #FF8A80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Overpass', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

h1, h2, p { margin: 0; }

button, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

/* ---- wordmark: the huvudled diamond + name ---------------------------- */

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.55em;
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.mark {
  width: 0.9em;
  height: 0.9em;
  flex: none;
  transform: rotate(45deg);
  border-radius: 2px;
  background: var(--yellow);
  box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 3.5px var(--ink);
}

/* ---- the plate: a sign's inset keyline ---------------------------------- */

.plate {
  background: var(--plate);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--rule);
}

/* ---- top bar ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px var(--gap);
}

.topbar form { margin-left: auto; }

.conn {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--danger);
}

.text-button {
  border: 0;
  padding: 6px 2px;
  background: none;
  color: var(--ink-soft);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.text-button:hover { color: var(--ink); }

/* ---- the "everyone's ready" strip that stays after the overlay ---------- */

.banner {
  position: relative;
  background: var(--yellow);
  color: var(--on-yellow);
  padding: 14px var(--gap) 20px;
}
.banner::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 6px;
  background: repeating-linear-gradient(-45deg, var(--on-yellow) 0 10px, var(--yellow) 10px 20px);
}
.banner p {
  max-width: 1120px;
  margin: 0 auto;
  font-size: 1.0625rem;
}
.banner strong { font-weight: 800; }

/* ---- layout ------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--gap);
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---- the car: three people ---------------------------------------------- */

.summary {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.people {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 520px) {
  .people { grid-template-columns: minmax(0, 1fr); }
}

.person {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 112px;
  padding: 18px 16px 16px;
  border-radius: var(--radius);
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--rule);
  transition: background-color 200ms ease, box-shadow 200ms ease;
}

@media (max-width: 520px) {
  .person { min-height: 0; padding: 14px 16px; }
}

/* A ready plate becomes a sign: solid yellow, white band, dark keyline. */
.person.is-ready {
  background: var(--yellow);
  color: var(--on-yellow);
  box-shadow: inset 0 0 0 2px var(--on-yellow), inset 0 0 0 5px #FFFFFF;
}

.person-name {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.person-status {
  font-size: 0.9375rem;
  color: var(--ink-soft);
}
.person.is-ready .person-status { color: var(--on-yellow); font-weight: 600; }

.person-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--ink-soft);
}
.person.is-online .person-dot { background: var(--online); box-shadow: none; }
.person.is-ready .person-dot { box-shadow: inset 0 0 0 2px var(--on-yellow); }
.person.is-ready.is-online .person-dot { background: var(--on-yellow); }

/* ---- the one action ----------------------------------------------------- */

.ready-btn {
  display: block;
  width: 100%;
  min-height: 84px;
  padding: 18px 24px;
  border: 0;
  border-radius: var(--radius);
  background: var(--blue);
  color: var(--on-blue);
  box-shadow: inset 0 0 0 4px var(--blue), inset 0 0 0 6px var(--on-blue);
  font-size: clamp(1.25rem, 3vw, 1.625rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
}
.ready-btn:hover { background: var(--blue-press); box-shadow: inset 0 0 0 4px var(--blue-press), inset 0 0 0 6px var(--on-blue); }
.ready-btn:active { transform: translateY(1px); }

/* Pressed: the button steps back so the yellow plate above carries the news. */
.ready-btn.is-ready {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--rule);
  font-size: 1.125rem;
  font-weight: 700;
  min-height: 60px;
}
.ready-btn.is-ready:hover { box-shadow: inset 0 0 0 2px var(--ink-soft); }

.ready-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.alerts { margin-top: 14px; }

.hint {
  font-size: 0.875rem;
  color: var(--ink-soft);
  max-width: 60ch;
}

/* ---- chat --------------------------------------------------------------- */

.chat {
  display: flex;
  flex-direction: column;
  height: min(70vh, 560px);
  padding: 18px 18px 14px;
}

@media (max-width: 860px) {
  .chat { height: 460px; }
}

.chat-title {
  font-size: 1.125rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.chat-log {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-empty {
  flex: 1;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.chat-log:not(:empty) + .chat-empty { display: none; }
.chat-log:empty { flex: 0; }

.msg {
  padding: 8px 0 8px 12px;
  border-left: 3px solid transparent;
}
.msg + .msg { margin-top: 2px; }
.msg.is-me { border-left-color: var(--blue); }

.msg-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
.msg-name { font-weight: 700; color: var(--ink); }

.msg-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

input {
  min-width: 0;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--ground);
  box-shadow: inset 0 0 0 1px var(--rule);
}
input:focus-visible { outline-offset: 1px; }

.chat-form input { flex: 1; }

.send-button {
  flex: none;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: var(--on-blue);
  font-weight: 700;
  cursor: pointer;
}
.send-button:hover { background: var(--blue-press); }
.send-button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- the moment: full-screen sign yellow -------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 72px 24px;
  overflow-y: auto;
  background: var(--yellow);
  color: var(--on-yellow);
  animation: overlay-in 260ms ease-out;
}

.overlay::before,
.overlay::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 36px;
  background: repeating-linear-gradient(-45deg, var(--on-yellow) 0 22px, var(--yellow) 22px 44px);
  background-size: 62.2254px 62.2254px; /* 44px stripe period along the diagonal */
  animation: stripes 1.6s linear infinite;
}
.overlay::before { top: 0; }
.overlay::after { bottom: 0; animation-direction: reverse; }

.overlay-inner { width: min(100%, 1040px); }

.overlay-title {
  font-size: clamp(2.75rem, 9vw, 6.5rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.035em;
}

.overlay-desc {
  margin-top: 0.9em;
  font-size: clamp(1.125rem, 2.4vw, 1.5rem);
  font-weight: 600;
  max-width: 34ch;
}

.overlay-button {
  margin-top: 1.6em;
  padding: 16px 40px;
  border: 0;
  border-radius: var(--radius);
  background: var(--on-yellow);
  color: var(--yellow);
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
}
.overlay-button:focus-visible { outline-color: var(--on-yellow); outline-offset: 4px; }

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes stripes {
  from { background-position: 0 0; }
  to { background-position: 62.2254px 0; }
}

/* ---- login -------------------------------------------------------------- */

.login {
  max-width: 400px;
  margin: 0 auto;
  padding: clamp(40px, 12vh, 120px) 16px 40px;
}

.login .wordmark { font-size: 2.25rem; }

.login-lede {
  margin: 14px 0 28px;
  color: var(--ink-soft);
  max-width: 34ch;
}

.login-form {
  display: flex;
  flex-direction: column;
  padding: 22px;
}

.login-form label {
  font-weight: 700;
  font-size: 0.9375rem;
  margin-bottom: 6px;
}

.login-form input { margin-bottom: 16px; }

.login-error {
  min-height: 1.5em;
  margin-bottom: 8px;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.9375rem;
}

.sign-button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: var(--on-blue);
  box-shadow: inset 0 0 0 3px var(--blue), inset 0 0 0 5px var(--on-blue);
  font-size: 1.125rem;
  font-weight: 800;
  cursor: pointer;
}
.sign-button:hover { background: var(--blue-press); box-shadow: inset 0 0 0 3px var(--blue-press), inset 0 0 0 5px var(--on-blue); }
.sign-button:disabled { opacity: 0.6; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
