/* Opintotodiste - visual language follows findynet.fi: electric blue, deep
   navy and cyan on a white page, a wide grotesk for display type (Archivo at
   its widest standing in for Findynet's Loos Wide), pill buttons, large
   radii. */

:root {
  --blue: #0901b9;
  --navy: #0d0342;
  --navy-2: #0b064d;
  --cyan: #8de4fe;
  --orange: #ff7510;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: var(--hero-bg);
  --text: #282539;
  --heading: var(--navy);
  --muted: #5b5870;
  --line: #ececf2;
  --line-strong: var(--navy);
  --link: var(--blue);
  --link-hover: var(--navy-2);
  --primary-bg: var(--blue);
  --primary-fg: #ffffff;
  --primary-hover: var(--navy-2);
  --focus: var(--blue);
  --icon-bg: var(--hero-bg);
  --icon-bg-strong: var(--cyan);
  --icon-fg: var(--navy);
  --success-bg: #e3f6ea;
  --success-fg: #14622f;
  --error-bg: #fdecea;
  --error-fg: #8c2322;
  --error-line: #f0bebc;
  --backdrop: rgba(13, 3, 66, 0.55);
  --hero-bg: #ebf9fd;

  --font-display: 'Archivo Variable', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-body: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --gutter: clamp(16px, 4vw, 64px);
  --content: 1200px;

  color-scheme: light;

  /* translate-element's own switcher palette */
  --translate-element-color-text: var(--heading);
  --translate-element-color-background: transparent;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--navy);
    --surface: #16104f;
    --surface-soft: #211a66;
    --text: #ecebf7;
    --heading: #ffffff;
    --muted: #b8b4d9;
    --line: rgba(235, 249, 252, 0.12);
    --line-strong: var(--cyan);
    --link: var(--cyan);
    --link-hover: #ffffff;
    --primary-bg: var(--cyan);
    --primary-fg: var(--navy);
    --primary-hover: #c4f1ff;
    --focus: var(--cyan);
    --icon-bg: #211a66;
    --icon-bg-strong: var(--cyan);
    --icon-fg: #ffffff;
    --success-bg: #123d2a;
    --success-fg: #9be7b6;
    --error-bg: #3b1026;
    --error-fg: #ffc2bd;
    --error-line: #7a2a3a;
    --backdrop: rgba(4, 1, 24, 0.7);
    --hero-bg: var(--surface);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 800;
  color: var(--heading);
  line-height: 1.15;
  margin: 0;
}
h2 { font-size: 1.6rem; }
h3 { font-size: 1.1rem; }

p { margin: 0; }

a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--link-hover); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.muted { color: var(--muted); font-size: .95rem; }

/* ---------- buttons & inputs ---------- */

button, a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  min-height: 48px;
  padding: 0 1.4rem;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--heading);
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .02em;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
button:hover, a.button:hover { background: var(--heading); color: var(--bg); }
a.button { text-decoration: none; }
button:focus-visible { border-radius: 999px; }
button:disabled { opacity: .5; cursor: default; }
button:disabled:hover { background: transparent; color: var(--heading); }
button.busy::after { content: '\2026'; }

button.primary, a.button.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); }
button.primary:hover, a.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-fg); }
button.primary:disabled:hover { background: var(--primary-bg); border-color: var(--primary-bg); }

button.small, a.button.small { min-height: 40px; padding: 0 1rem; font-size: .85rem; }
button.ghost, a.button.ghost { border-color: transparent; }
button.ghost:hover, a.button.ghost:hover { background: var(--surface-soft); color: var(--heading); }
button.danger { color: var(--error-fg); }
button.danger:hover { background: var(--error-bg); color: var(--error-fg); }

.link-btn {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--link);
  font: inherit;
  letter-spacing: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-align: left;
}
.link-btn:hover { background: none; color: var(--link-hover); }

input[type=url], input[type=text], select {
  min-height: 56px;
  padding: 0 1.1rem;
  border: 2px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
select { min-height: 44px; padding: 0 .8rem; border-width: 1px; border-color: var(--line); border-radius: 10px; font-size: .95rem; }
input::placeholder { color: var(--muted); }
/* A text field and its button in one white pill, for use on the cyan hero. */
.field-row {
  display: flex;
  gap: 10px;
  padding: 7px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(17, 72, 119, .08);
}
.field-row input { flex: 1; min-width: 0; min-height: 48px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; }
.field-row input:focus-visible { outline-offset: 0; border-radius: 999px; }
.field-row button { min-height: 48px; padding: 0 1.6rem; }
/* The dark hero is the surface colour itself, so the pill steps up a shade. */
@media (prefers-color-scheme: dark) {
  .field-row { background: var(--surface-soft); }
}
input[type=checkbox], input[type=radio] {
  width: 22px;
  height: 22px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--blue);
  cursor: pointer;
}

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

.topbar, .hero, .page-hero {
  width: min(100% - 2 * var(--gutter), var(--content));
  margin-inline: auto;
}

/* Fixed slots (src/views/layout.js): the site nav starts right after the brand
   and the account slot has a fixed width, so signing in or out, or a page
   without sign-in, moves nothing. */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr var(--account-slot) auto;
  grid-template-areas: "brand nav account lang";
  align-items: center;
  gap: 12px 24px;
  padding: 20px 0;
  --account-slot: 13rem;
}
.brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--heading);
  text-decoration: none;
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: 1.2rem;
}
.brand:hover { color: var(--heading); }
.brand svg { color: var(--link); }
.site-nav { grid-area: nav; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.site-nav a { font-weight: 700; color: var(--heading); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current=page] { color: var(--link); text-decoration: underline; text-underline-offset: 6px; }
.topbar translate-element { grid-area: lang; }
.auth-nav { grid-area: account; position: relative; display: flex; justify-content: flex-end; min-width: 0; min-height: 44px; }
/* The display name opens the account menu (public/auth.js); the menu shows
   it in full. */
.auth-nav .account-btn { max-width: 100%; min-height: 44px; padding: 0 .9rem; border-width: 1px; font-size: .85rem; }
.auth-nav .account-btn::after { content: ''; flex-shrink: 0; width: .45em; height: .45em; margin: -.2em 0 0 .1em; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.auth-nav .account-btn[aria-expanded=true]::after { margin-top: .2em; transform: rotate(-135deg); }
.account-icon { display: inline-flex; flex-shrink: 0; color: var(--link); }
.account-btn:hover .account-icon { color: inherit; }
.account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: max(100%, 16rem);
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(13, 3, 66, .2);
}
.account-menu:focus { outline: none; }
.account-menu-name { padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--line); color: var(--heading); font-weight: 700; overflow-wrap: anywhere; }
.account-menu ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.account-menu a, .account-menu .link-btn { display: block; width: 100%; padding: 8px 0; color: var(--heading); font-weight: 700; text-decoration: none; }
.account-menu a:hover, .account-menu .link-btn:hover { color: var(--link); text-decoration: underline; }
.account-menu .row-error { margin-top: 8px; }

/* translate-element's language switcher, placed in the top bar */
.translate-element { position: static; }
.translate-element ul {
  height: auto;
  margin: 0;
  padding: 0;
  gap: 2px;
  border: 0;
  background: transparent;
}
.translate-element li {
  width: auto;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
}
.translate-element li.selected { padding: 0; border: 0; background: var(--heading); color: var(--bg); }
.translate-element a { display: block; padding: 10px 12px; line-height: 1; }
.translate-element a:hover { color: inherit; }


.page-hero { display: flex; flex-direction: column; gap: 16px; padding: 32px 0 48px; }
.page-hero h1 { font-size: clamp(2rem, 4.5vw, 3rem); letter-spacing: -.015em; }
.eyebrow {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--link);
}

/* The white sheet that holds a page's working content. */
.panel {
  flex: 1;
  width: min(100% - 2 * clamp(8px, 2vw, 24px), calc(var(--content) + 48px));
  margin-inline: auto;
  padding: 40px clamp(16px, 3vw, 40px) 64px;
  border-radius: 40px 40px 0 0;
  background: var(--surface);
}
.panel[hidden] { display: none; }

/* ---------- messages ---------- */

.error {
  padding: 14px 18px;
  border: 1px solid var(--error-line);
  border-radius: 14px;
  background: var(--error-bg);
  color: var(--error-fg);
}
.row-error { color: var(--error-fg); font-size: .9rem; }
.empty { padding: 32px 0; color: var(--muted); }


dialog .field { display: flex; flex-direction: column; align-items: stretch; gap: 6px; font-weight: 700; color: var(--heading); }

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

dialog {
  width: min(560px, 100% - 32px);
  max-height: calc(100vh - 48px);
  padding: 32px;
  border: 0;
  border-radius: 28px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(13, 3, 66, .3);
}
dialog::backdrop { background: var(--backdrop); }
dialog > div > * + *, dialog form { margin-top: 16px; }
dialog h2 { font-size: 1.45rem; padding-right: 8px; }
dialog h3 { margin-bottom: 8px; }
dialog p:has(> button) { display: flex; flex-wrap: wrap; gap: 10px; }
dialog label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
dialog input[type=text] { min-height: 48px; }
dialog table { width: 100%; border-collapse: collapse; }
dialog td { padding: 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
dialog td + td { padding-left: 16px; text-align: right; font-weight: 700; }
dialog img { display: block; margin: 8px 0; border-radius: 12px; background: #ffffff; padding: 8px; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; }
dt { font-weight: 700; color: var(--heading); }
dd { margin: 0; }

.wallet-offer + .wallet-offer { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.wallet-offer[data-state]:not([data-state="waiting"]) img { opacity: .25; }
.wallet-offer:is([data-state="picked-up"], [data-state="stored"]) .offer-status strong { color: var(--success-fg); }
.wallet-offer[data-state="failed"] .offer-status strong { color: var(--error-fg); }

/* ---------- footer ---------- */

.site-footer {
  width: min(100% - 2 * var(--gutter), var(--content));
  margin: auto auto 0;
  padding: 32px 0;
  border-top: 1px solid var(--line);
  font-size: .95rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover, .site-footer a[aria-current=page] { color: var(--link); }
/* Room for the main page's fixed selection bar. */
.page-main .site-footer { padding-bottom: 120px; }

/* ---------- small screens ---------- */

/* Two rows when one doesn't fit: brand and languages, then the site nav and
   the account slot. */
@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: 1fr var(--account-slot);
    grid-template-areas: "brand lang" "nav account";
  }
  .topbar translate-element { justify-self: end; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .topbar { --account-slot: 9.5rem; }
  .field-row { flex-direction: column; padding: 0; background: none; box-shadow: none; }
  .field-row input { min-height: 52px; background: var(--surface); }
  .field-row button { min-height: 52px; }
  dialog { padding: 24px; }
}
