/* Zukko base: fonts, colour tokens, type, buttons, fields, dialogs, toasts.
   Palette from Samarkand tilework: lapis ink, Registan turquoise, saffron, pomegranate. */

@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/golos-text-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/golos-text-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/golos-text-cyrillic-wght-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/golos-text-cyrillic-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url(../fonts/unbounded-display.woff2) format('woff2');
  unicode-range: U+0020-007E, U+00A0, U+00D7, U+2013-2014, U+2212;
}

:root {
  --ink: #16233f;
  --ink-soft: #45536e;
  --ink-faint: #6f7c95;
  --ground: #eef2f7;
  --paper: #ffffff;
  --paper-sunk: #f5f7fb;
  --line: #d7dee9;
  --line-strong: #b6c1d2;

  --tile: #0b7a7d;
  --tile-deep: #075e61;
  --tile-edge: #05484a;
  --tile-bright: #17a3a6;
  --tile-wash: #dcf0ef;
  --tile-ink: #ffffff;
  --ring: rgba(11, 122, 125, 0.3);

  --saffron: #e3a008;
  --saffron-wash: #fcf0d2;
  --pomegranate: #c2334d;
  --pomegranate-wash: #f9e2e6;
  --leaf: #1a7f45;
  --leaf-wash: #def2e5;
  --slate: #4e5d73;

  /* Answer colours. Each one also has a shape, so colour is never the only cue. */
  --opt-1: #2a4fb0;
  --opt-1-edge: #1c387f;
  --opt-2: #b06a00;
  --opt-2-edge: #7e4c00;
  --opt-3: #c2334d;
  --opt-3-edge: #8e2236;
  --opt-4: #0b7a7d;
  --opt-4-edge: #05484a;
  --opt-5: #6c4ab6;
  --opt-5-edge: #4d3384;
  --opt-6: #4e5d73;
  --opt-6-edge: #354052;

  --focus: #2a4fb0;
  --font-ui: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Arabic', Tahoma, Arial, sans-serif;
  --font-display: 'Unbounded', 'Golos Text', system-ui, sans-serif;

  --r-input: 10px;
  --r-btn: 12px;
  --r-panel: 14px;
  --r-tile: 16px;
  --lift: 0 12px 32px rgba(22, 35, 63, 0.18), 0 2px 6px rgba(22, 35, 63, 0.08);
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ink: #e9eef7;
    --ink-soft: #b5c0d3;
    --ink-faint: #8b97ad;
    --ground: #0e172c;
    --paper: #16213b;
    --paper-sunk: #121c33;
    --line: #2a3a5c;
    --line-strong: #3d5078;
    --tile: #23b2b4;
    --tile-deep: #1b9597;
    --tile-edge: #0f6668;
    --tile-bright: #4fd0d2;
    --tile-wash: #12393f;
    --tile-ink: #032326;
    --ring: rgba(35, 178, 180, 0.35);
    --saffron-wash: #3a2e10;
    --pomegranate: #e2576f;
    --pomegranate-wash: #3d1a22;
    --leaf: #3db56f;
    --leaf-wash: #133524;
    --focus: #8fb0ff;
    --lift: 0 12px 32px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --ink: #e9eef7;
  --ink-soft: #b5c0d3;
  --ink-faint: #8b97ad;
  --ground: #0e172c;
  --paper: #16213b;
  --paper-sunk: #121c33;
  --line: #2a3a5c;
  --line-strong: #3d5078;
  --tile: #23b2b4;
  --tile-deep: #1b9597;
  --tile-edge: #0f6668;
  --tile-bright: #4fd0d2;
  --tile-wash: #12393f;
  --tile-ink: #032326;
  --ring: rgba(35, 178, 180, 0.35);
  --saffron-wash: #3a2e10;
  --pomegranate: #e2576f;
  --pomegranate-wash: #3d1a22;
  --leaf: #3db56f;
  --leaf-wash: #133524;
  --focus: #8fb0ff;
  --lift: 0 12px 32px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
p,
ul,
ol {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

img,
svg {
  display: block;
}

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

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

[hidden] {
  display: none !important;
}

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

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

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

/* Answer colour pairs, used by the phone, the editor and the big screen. */
.c1 { --c: var(--opt-1); --edge: var(--opt-1-edge); }
.c2 { --c: var(--opt-2); --edge: var(--opt-2-edge); }
.c3 { --c: var(--opt-3); --edge: var(--opt-3-edge); }
.c4 { --c: var(--opt-4); --edge: var(--opt-4-edge); }
.c5 { --c: var(--opt-5); --edge: var(--opt-5-edge); }
.c6 { --c: var(--opt-6); --edge: var(--opt-6-edge); }

/* ----- brand ----- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
}

.brand-mark {
  width: 30px;
  height: 30px;
}

.brand-star {
  fill: var(--tile);
}

.brand-dot {
  fill: var(--saffron);
}

.brand-word {
  font: 700 1.3125rem/1 var(--font-display);
  letter-spacing: -0.02em;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 10px max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-picker {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--paper)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%236f7c95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 8px center / 16px;
  border-radius: 999px;
  padding: 7px 30px 7px 14px;
  font-size: 0.9375rem;
  font-weight: 500;
  min-height: 40px;
  cursor: pointer;
}

/* ----- buttons ----- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border: 1.5px solid transparent;
  border-radius: var(--r-btn);
  font: 600 1rem/1.2 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn:active:not([disabled]) {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--tile);
  color: var(--tile-ink);
  box-shadow: 0 3px 0 var(--tile-edge);
}

.btn-primary:hover:not([disabled]) {
  background: var(--tile-deep);
}

.btn-quiet {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-quiet:hover:not([disabled]) {
  border-color: var(--ink-faint);
  background: var(--paper-sunk);
}

.btn-plain {
  background: transparent;
  color: var(--ink-soft);
  padding-inline: 10px;
}

.btn-plain:hover:not([disabled]) {
  background: var(--paper-sunk);
  color: var(--ink);
}

.btn-danger {
  background: var(--pomegranate);
  color: #fff;
  box-shadow: 0 3px 0 #8e2236;
}

.btn-big {
  min-height: 56px;
  padding: 14px 24px;
  font-size: 1.125rem;
  border-radius: 14px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  flex: none;
}

.icon-btn:hover:not([disabled]) {
  background: var(--paper-sunk);
  color: var(--ink);
}

.icon-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ----- fields ----- */

.field {
  display: grid;
  gap: 6px;
}

.label {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--ink);
}

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

.input,
.textarea,
.select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-input);
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea {
  resize: vertical;
  min-height: 90px;
}

.select {
  appearance: none;
  padding-right: 36px;
  background: var(--paper)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%236f7c95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 10px center / 18px;
  cursor: pointer;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--tile);
  box-shadow: 0 0 0 3px var(--ring);
}

.input.is-invalid,
.textarea.is-invalid {
  border-color: var(--pomegranate);
}

.form-error {
  color: var(--pomegranate);
  font-weight: 500;
  font-size: 0.9375rem;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9375rem;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--tile);
  flex: none;
}

/* ----- the six-digit code, entered as glazed tiles ----- */

.code-entry {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.code-entry .code-gap {
  width: 6px;
}

.code-cell {
  display: grid;
  place-items: center;
  width: 44px;
  height: 56px;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: 700 1.75rem/1 var(--font-display);
  transition: background-color 0.12s, border-color 0.12s, transform 0.12s;
}

.code-cell.is-filled {
  border-color: var(--tile-deep);
  background: linear-gradient(155deg, var(--tile-bright) 0%, var(--tile) 58%, var(--tile-deep) 100%);
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22), 0 3px 0 var(--tile-edge);
}

.code-entry.is-focused .code-cell.is-next {
  border-color: var(--tile);
  box-shadow: 0 0 0 3px var(--ring);
}

.code-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  font-size: 16px;
  color: transparent;
  caret-color: transparent;
  cursor: text;
}

.code-entry.is-error .code-cell {
  border-color: var(--pomegranate);
}

@media (min-width: 440px) {
  .code-cell {
    width: 50px;
    height: 62px;
  }
}

@media (max-width: 370px) {
  .code-cell {
    width: 38px;
    height: 50px;
    font-size: 1.375rem;
  }
  .code-entry {
    gap: 5px;
  }
  .code-entry .code-gap {
    width: 2px;
  }
}

/* ----- toasts ----- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(480px, calc(100% - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  box-shadow: var(--lift);
  pointer-events: auto;
}

.toast-error {
  background: var(--pomegranate);
  color: #fff;
}

.toast-action {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 6px;
}

/* ----- dialogs ----- */

.dialog {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: var(--r-panel);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--lift);
}

.dialog[open] {
  display: block;
}

.dialog::backdrop {
  background: rgba(14, 23, 44, 0.55);
}

.dialog-inner {
  display: grid;
  gap: 0;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 8px 22px;
}

.dialog-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 6px 22px 18px;
  color: var(--ink-soft);
}

.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--line);
}

.noscript {
  max-width: 480px;
  margin: 40px auto;
  padding: 0 var(--gutter);
  text-align: center;
}

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