/* Samiportal: design A ("Paper") layout with the original site colours. */

/* Fonts: self-hosted Noto, subset to Latin + Skolt Sami (see README). */
@font-face { font-family: "Noto Sans"; src: url("fonts/noto-sans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Noto Serif"; src: url("fonts/noto-serif.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Noto Serif"; src: url("fonts/noto-serif-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Noto Serif Display"; src: url("fonts/noto-serif-display.woff2") format("woff2"); font-weight: 500 700; font-display: swap; }

/* Colour tokens. Names follow the original site; see PLAN.md "Decisions". */
:root {
  color-scheme: light;
  --primary-color: #2563eb;   /* accents, links, kicker labels, step numbers, progress bar, focus ring */
  --primary-dark: #1d4ed8;    /* hover */
  --secondary-color: #10b981; /* play buttons, success: backgrounds and icons only, never text */
  --on-secondary: #052e1f;    /* icon/text on top of the green */
  --accent-color: #f59e0b;    /* highlights, "In preparation" tags (as a background) */
  --on-accent: #1f2937;
  --text-primary: #1f2937;
  --text-secondary: #4b5563;  /* the original #6b7280 is too light on the grey panels (4.3:1) */
  --bg-primary: #ffffff;      /* as on the live site (chosen 2026-11-17) */
  --bg-secondary: #f8fafc;    /* every other section, as on the live site */
  --bg-accent: #f1f5f9;
  --border-color: #e2e8f0;
  --heading: #2563eb;         /* headings in blue, as on the live site */
  --footer-bg: #1f2937;       /* dark footer, as on the live site */
  --footer-text: #ffffff;
  --card: #ffffff;
  --shadow: rgb(15 23 42 / .18);

  --serif: "Noto Serif", Georgia, serif;
  --display: "Noto Serif Display", "Noto Serif", Georgia, serif;
  --sans: "Noto Sans", system-ui, sans-serif;
}

/* Dark mode, only when the visitor switches it on (assets/theme.js): same hues, slate background,
   lighter blue/green. Light is the default even when the computer itself is set to dark. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --primary-color: #60a5fa;
  --primary-dark: #93c5fd;
  --secondary-color: #34d399;
  --on-secondary: #022c22;
  --accent-color: #fbbf24;
  --on-accent: #1f2937;
  --text-primary: #e2e8f0;
  --text-secondary: #a3b1c6;
  --bg-primary: #0f172a;
  --bg-secondary: #172033;
  --bg-accent: #1e293b;
  --border-color: #334155;
  --card: #1e293b;
  --shadow: rgb(0 0 0 / .5);
  --heading: var(--text-primary);
  --footer-bg: #0b1222;
  --footer-text: #cbd5e1;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); background: var(--bg-primary); color: var(--text-primary); line-height: 1.65; font-size: 1.0625rem; }
[lang="sms"] { font-family: var(--serif); }
a { color: var(--primary-color); text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); }
:focus-visible { outline: 3px solid var(--primary-color); outline-offset: 3px; border-radius: 2px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 1rem; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Masthead */
.masthead { border-bottom: 1px solid var(--border-color); padding: 2.5rem 0 1.25rem; text-align: center; }
.masthead h1 { font-weight: inherit; }
.sms-title { display: block; font-family: var(--display); font-weight: 700; font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.05; letter-spacing: -.01em; }
.site-name { display: flex; align-items: center; justify-content: center; white-space: nowrap; font-family: var(--sans); text-transform: uppercase; letter-spacing: .25em; font-size: .8rem; color: var(--text-secondary); margin-top: .6rem; }
/* The rules beside the name shrink on narrow screens instead of wrapping onto a line of their own */
.site-name::before, .site-name::after { content: ""; flex: 0 1 2.5rem; min-width: .75rem; height: 1px; background: var(--border-color); margin: 0 .8rem; }
.langs { margin-top: 1rem; font-size: .9rem; }
.langs ul { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem .5rem; }
.langs a { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--text-secondary); text-decoration: none; padding: 0 .5rem; }
.langs a:hover { color: var(--primary-color); }
.langs a[aria-current] { color: var(--text-primary); font-weight: 700; box-shadow: inset 0 -2px var(--primary-color); }

.theme-switch { font: inherit; font-size: .9rem; margin-top: .5rem; min-height: 2.75rem; padding: .4rem .9rem; border: 1px solid var(--border-color); background: transparent; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: .45rem; }
.theme-switch:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.theme-switch svg { width: 1.05rem; height: 1.05rem; }

/* Section navigation: sticky, scrolls sideways on phones */
nav.toc { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg-primary) 96%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-bottom: 1px solid var(--border-color); }
nav.toc ul { list-style: none; display: flex; gap: 0 1rem; justify-content: center; overflow-x: auto; padding: 0 1rem; scrollbar-width: none; }
nav.toc a { display: block; min-width: 2.75rem; text-align: center; padding: .8rem .2rem; color: var(--text-primary); text-decoration: none; font-size: .92rem; white-space: nowrap; }
nav.toc a:hover { color: var(--primary-color); }

section { padding: 4rem 0; border-bottom: 1px solid var(--border-color); }
.kicker { font-size: .78rem; text-transform: uppercase; letter-spacing: .18em; color: var(--primary-color); font-weight: 700; margin-bottom: .5rem; }
h2 { color: var(--heading); font-family: var(--display); font-weight: 500; font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.15; margin-bottom: 1rem; }
h3, .h3 { color: var(--heading); font-family: var(--display); font-weight: 500; font-size: 1.35rem; line-height: 1.25; margin-bottom: .75rem; }
.lede { font-family: var(--serif); font-size: 1.2rem; max-width: 40rem; }
p + p { margin-top: .9rem; }

/* Home */
.home-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 3rem; align-items: start; }
.steps { list-style: none; counter-reset: s; border-left: 1px solid var(--border-color); margin-top: 1.25rem; }
.steps li { counter-increment: s; position: relative; padding: 0 0 1.4rem 3.4rem; }
.steps li::before { content: counter(s); position: absolute; left: 1rem; top: -.35rem; font-family: var(--display); font-size: 2rem; color: var(--primary-color); line-height: 1; }
.closing { margin-top: 1.5rem; font-style: italic; font-family: var(--serif); }

/* Dictionary (top 100 words) */
.dict { list-style: none; columns: 2; column-gap: 3rem; column-rule: 1px solid var(--border-color); margin-top: 2rem; }
.entry { break-inside: avoid; display: grid; grid-template-columns: 2.4rem 1fr auto; align-items: baseline; gap: .5rem; padding: .6rem 0; border-bottom: 1px dotted var(--border-color); }
.entry .n { font-size: .75rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.entry .w { font-weight: 700; font-size: 1.15rem; margin-right: .35rem; }
.entry .t { font-family: var(--serif); font-style: italic; color: var(--text-secondary); font-size: .98rem; }
.note { margin-top: 1.5rem; font-size: .9rem; color: var(--text-secondary); font-style: italic; }

/* Play button */
.play { --s: 2.75rem; width: var(--s); height: var(--s); border-radius: 50%; border: 0; background: var(--secondary-color); color: var(--on-secondary); cursor: pointer; display: grid; place-items: center; flex: none; }
.play:hover { filter: brightness(1.08); }
.play svg { width: 50%; height: 50%; }
.play.is-playing { box-shadow: 0 0 0 3px var(--bg-primary), 0 0 0 6px var(--secondary-color); }
.phrase-sms { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.fc-stage { position: relative; }
.fc-play { position: absolute; top: .75rem; right: .75rem; z-index: 2; }
.fc-check { display: flex; align-items: center; min-height: 2.75rem; }
.fc-check label { display: inline-flex; align-items: center; min-height: 2.75rem; gap: .5rem; cursor: pointer; }
.fc-check input { width: 1.25rem; height: 1.25rem; accent-color: var(--primary-color); }

/* Flashcards */
.fc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 3rem; align-items: start; margin-top: 2rem; }
.fc-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .25rem 1rem; font-size: .9rem; color: var(--text-secondary); margin-bottom: .6rem; }
.fc-meta p + p { margin-top: 0; }
.bar { height: 4px; background: var(--bg-accent); margin-bottom: 1.25rem; }
.bar span { display: block; width: 0; height: 100%; background: var(--primary-color); transition: width .3s; }
.flashcard { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 17rem; perspective: 1200px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: center; }
.fc-inner { position: relative; display: block; height: 100%; transition: transform .6s; transform-style: preserve-3d; }
.flashcard.is-flipped .fc-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--card); border: 1px solid var(--border-color); box-shadow: 0 1px 0 var(--border-color), 0 12px 30px -18px var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; padding: 1.5rem 1.5rem 1.5rem 3.5rem;
  /* Notebook lines every 2.1rem, placed from the middle of the card so that one runs exactly under
     the word's baseline. The word is centred, so its baseline sits 0.388 × font size − 1.076rem from
     the middle (Noto: ascent 1.069, descent 0.293; the hint below is 1.4rem tall, plus the .75rem gap).
     A 50% position on a 2.1rem tile starts it 1.05rem above the middle; the line is its bottom pixel. */
  background-image: linear-gradient(to bottom, transparent calc(2.1rem - 1px), color-mix(in srgb, var(--primary-color) 14%, transparent) calc(2.1rem - 1px));
  background-size: 100% 2.1rem; background-position: 0 calc(50% + .388 * var(--fs) - 2.126rem + 1px); }
.front { --fs: clamp(1.8rem, 9vw, 3.4rem); }
.back { --fs: clamp(1.4rem, 6vw, 2.2rem); }
.face::before { content: ""; position: absolute; top: 0; bottom: 0; left: 2.5rem; width: 1px; background: color-mix(in srgb, var(--accent-color) 70%, transparent); }
.back { transform: rotateY(180deg); }
/* The side facing away is also hidden outright, exactly half-way through the .6s turn.
   This works even where backface-visibility doesn't, and screen readers only read the visible side. */
.face { transition: visibility 0s .3s; }
.back, .flashcard.is-flipped .front { visibility: hidden; }
.flashcard.is-flipped .back { visibility: visible; }
.fc-word { font-family: var(--display); font-weight: 700; font-size: var(--fs); line-height: 1.1; overflow-wrap: anywhere; }
.fc-trans { font-family: var(--serif); font-style: italic; font-size: var(--fs); line-height: 1.2; overflow-wrap: anywhere; }
.fc-hint { font-size: .85rem; color: var(--text-secondary); }
.fc-listen { color: var(--secondary-color); }
.fc-listen svg { display: block; width: 4.5rem; height: 4.5rem; }
.fc-sub { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; }
.controls { display: flex; gap: .75rem; justify-content: center; margin-top: 1.25rem; flex-wrap: wrap; }
.btn { font: inherit; font-size: .95rem; min-height: 2.75rem; padding: .55rem 1.1rem; border: 1px solid var(--text-primary); background: transparent; color: var(--text-primary); cursor: pointer; }
.btn:hover { background: var(--text-primary); color: var(--bg-primary); }
.btn.alt { border-color: var(--primary-color); color: var(--primary-color); }
.btn.alt:hover { background: var(--primary-color); color: var(--bg-primary); }
.btn.gotit { background: var(--secondary-color); border-color: var(--secondary-color); color: var(--on-secondary); font-weight: 600; }
.btn.gotit:hover { filter: brightness(1.08); background: var(--secondary-color); color: var(--on-secondary); }
#fc-scoring .btn, #fc-reveal .btn { min-width: 9rem; }
.flashcard { touch-action: pan-y; }   /* sideways swipes go to the script, vertical ones still scroll the page */
.fc-tip { margin-top: .9rem; text-align: center; font-size: .85rem; color: var(--text-secondary); }

/* Direction and deck choice */
.fc-settings { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: .75rem 1.5rem; margin-bottom: 1.25rem; font-size: .92rem; }
.fc-dir { border: 0; display: flex; flex-wrap: wrap; }
.fc-dir legend, .fc-deck label { display: block; width: 100%; font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--text-secondary); font-weight: 600; margin-bottom: .3rem; }
.fc-dir label { position: relative; display: inline-flex; align-items: center; min-height: 2.75rem; padding: .4rem .9rem; border: 1px solid var(--border-color); cursor: pointer; }
.fc-dir label + label { border-left: 0; }
.fc-dir input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.fc-dir label:has(input:checked) { background: var(--text-primary); border-color: var(--text-primary); color: var(--bg-primary); }
.fc-dir label:has(input:focus-visible) { outline: 3px solid var(--primary-color); outline-offset: 2px; z-index: 1; }
.fc-settings p { margin-top: 0; }
/* Safari ignores the height of its own drop-down, so the site draws it (44px tall) with a CSS arrow */
.select { position: relative; display: inline-block; max-width: 100%; }
.select::after { content: ""; position: absolute; right: .9rem; top: 50%; width: .45rem; height: .45rem; margin-top: -.35rem; border: solid var(--text-primary); border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none; }
.fc-deck select { -webkit-appearance: none; appearance: none; font: inherit; min-height: 2.75rem; padding: .4rem 2.4rem .4rem .7rem; border: 1px solid var(--text-secondary); border-radius: 0; background: var(--bg-primary); color: var(--text-primary); max-width: 100%; cursor: pointer; }

/* End of session */
.fc-done { min-height: 17rem; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 2rem 1.5rem; background: var(--card); border: 1px solid var(--border-color); box-shadow: 0 1px 0 var(--border-color), 0 12px 30px -18px var(--shadow); }
.fc-done h3 { font-size: 1.8rem; }
.fc-done h3:focus { outline: none; }
.fc-done p { font-family: var(--serif); font-size: 1.15rem; max-width: 28rem; }

.howto { background: var(--bg-accent); padding: 1.5rem; font-size: .95rem; }
.howto ul { list-style: none; }
.howto li { padding: .45rem 0; border-top: 1px solid var(--border-color); }
.howto li:first-child { border-top: 0; }
.howto strong { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--primary-color); }

/* In preparation */
.soon { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--text-primary); border-bottom: 1px solid var(--text-primary); }
.soon > div { padding: 2rem 1.5rem; }
.soon > div + div { border-left: 1px solid var(--border-color); }
.soon .tag { display: inline-block; font-size: .7rem; letter-spacing: .15em; text-transform: uppercase; background: var(--accent-color); color: var(--on-accent); font-weight: 600; padding: .1rem .5rem; margin-bottom: .9rem; }
.soon p:not(.tag) { font-size: .95rem; color: var(--text-secondary); margin-top: 0; }

/* Phrasebook */
.phrases { width: 100%; border-collapse: collapse; margin-top: 2rem; }
.phrases th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .14em; color: var(--text-secondary); font-weight: 600; padding: .5rem .75rem .5rem 0; border-bottom: 1px solid var(--text-primary); }
.phrases td { padding: .9rem .75rem .9rem 0; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.phrases .w { font-weight: 700; font-size: 1.15rem; }
.phrases .hint { display: block; font-size: .85rem; color: var(--text-secondary); letter-spacing: .05em; }

/* About + footer */
.about { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; }
.contact { background: var(--card); border: 1px solid var(--border-color); padding: 1.75rem; }
.contact a { font-weight: 600; overflow-wrap: anywhere; }
footer { padding: 2rem 0 3rem; text-align: center; font-size: .85rem; background: var(--footer-bg); color: var(--footer-text); }
footer a { color: inherit; text-underline-offset: .15em; }
.about h3 { margin-top: 2rem; }
main > section:nth-of-type(even) { background: var(--bg-secondary); }

@media (max-width: 760px) {
  .home-grid, .fc-layout, .about { grid-template-columns: 1fr; gap: 2rem; }
  .dict { columns: 1; }
  .soon { grid-template-columns: 1fr; }
  .soon > div + div { border-left: 0; border-top: 1px solid var(--border-color); }
  /* The menu scrolls sideways on phones; the fade at the right edge shows there is more */
  nav.toc ul { justify-content: flex-start; padding-right: 2.5rem; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent); }
  section { padding: 3rem 0; }
  .flashcard { height: 14rem; }
  .fc-done { min-height: 14rem; }
}

@media (max-width: 400px) {
  .controls { gap: .5rem; }
  .btn { padding: .55rem .7rem; font-size: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bar span { transition: none; }
  /* No 3D turn: the translation fades in, and the next card appears at once */
  .fc-inner { transition: none; transform: none !important; }
  .front, .back { transform: none; transition: none; }
  .back { opacity: 0; }
  .flashcard.is-flipped .back { opacity: 1; transition: opacity .2s; }
}
