/* =====================================================================
   Muuseumide infosüsteem – teema: 18.–19. sajandi loodusteaduslik õppetahvel
   Kõik värvid, mõõdud ja fondid on muutujatena :root all. Muuseum saab neid üle kirjutada
   (nt <body style="--fuksia:#1d5e7a"> või [data-teema="..."] reegliga), vt komponendid.css lõpus.
   Kontrastid (WCAG AA) on mõõdetud paberi (#f1e6c8) vastu: tekst 12,8:1, hall 5,3:1, link 8,2:1.
   ===================================================================== */
:root {
  /* paber */
  --paber: #f1e6c8;
  --paber-hele: #f8f1dc;
  --paber-tume: #e8d9b0;
  --paber-lai: #f4ecd2;          /* töötaja vaate lame taust */
  /* tint ja jooned */
  --tint: #2a2018;               /* kulunud must tekst */
  --tint-pehme: #5e4128;         /* pruun: rõhud, topeltjooned */
  --hall: #6b5a45;               /* teisene tekst */
  --joon: #8a7350;               /* 1px tušijooned, vormiväljade ääred (3,6:1) */
  --joon-hele: #cdbb90;          /* punktiirjooned, tabeliread */
  /* värvid (matid akvarellitoonid) */
  --fuksia: #9a1d5a;             /* aktsent */
  --fuksia-tume: #7d1448;        /* lingid, esmane nupp (8,2:1) */
  --roheline: #3f5230;           /* vanutatud roheline: edu, avalik */
  --roheline-hele: #dfe3c4;
  --viga: #8c1c13;
  --viga-hele: #f0d7c6;
  --hoiatus-hele: #f1e0a8;
  /* tüpograafia */
  --f-tekst: "EB Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --f-pealkiri: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --f-tahvel: "IM Fell English", "Cormorant Garamond", Georgia, serif;   /* ainult kujunduselemendid (š/ž puuduvad) */
  --f-kiri: "Pinyon Script", "Cormorant Garamond", cursive;              /* käsitsikirjutatud aktsent, ainult lühikesed tekstid */
  /* mõõtmed */
  --laius: 64rem;
  --laius-pea: 64rem;           /* päis ja jalus joonduvad sisuga */
  --vahe: 1.25rem;
  /* tekstuur: peen müra + plekid (SVG, ilma välisfailideta) */
  --muster-myra: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .26 0 0 0 0 .14 0 0 0 .13 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --muster-plekid:
    radial-gradient(circle at 12% 16%, rgb(150 100 40 / .11), transparent 24%),
    radial-gradient(circle at 86% 28%, rgb(150 100 40 / .09), transparent 27%),
    radial-gradient(circle at 28% 78%, rgb(130 85 30 / .10), transparent 25%),
    radial-gradient(circle at 80% 90%, rgb(150 100 40 / .09), transparent 21%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 1rem; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  font-family: var(--f-tekst);
  font-size: 1.125rem; line-height: 1.55;
  color: var(--tint);
  background-color: var(--paber);
  background-image: var(--muster-myra), var(--muster-plekid);
  background-attachment: fixed;
  font-variant-numeric: lining-nums;
  font-kerning: normal; hanging-punctuation: first;
  overflow-wrap: break-word;
}
/* vinjett: kergelt tumenev serv */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, transparent 55%, rgb(110 75 30 / .20) 100%);
}
/* töötaja vaade: sama teema, aga lame paber ilma tekstuurita (pikaajaline andmesisestus vajab selgust) */
body.vaade-tootaja { background-color: var(--paber-lai); background-image: none; }
body.vaade-tootaja::before { background: radial-gradient(ellipse at 50% 30%, transparent 70%, rgb(110 75 30 / .08) 100%); }

@media (max-width: 40rem) { body { font-size: 1.0625rem; } }

/* ---------- tekst ---------- */
h1, h2, h3, h4 {
  font-family: var(--f-pealkiri); font-weight: 600; line-height: 1.12; color: var(--tint);
  margin: 0 0 .6em; text-wrap: balance;
}
h1 { font-size: clamp(2rem, 4.2vw + 1rem, 2.9rem); letter-spacing: -.005em; }
h2 { font-size: 1.7rem; margin-top: 2.2rem; }
h3 { font-size: 1.3rem; margin-top: 1.6rem; }
h2:first-child, h3:first-child { margin-top: 0; }
p, ul, ol, dl, table, form, fieldset { margin-top: 0; }
p { margin-bottom: 1em; }
small { font-size: .85em; }
strong { font-weight: 600; }
em, i { font-style: italic; }
hr { border: 0; height: 5px; border-top: 1px solid var(--joon); border-bottom: 1px solid var(--joon); margin: 2rem 0; opacity: .8; }

a { color: var(--fuksia-tume); text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--fuksia); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--fuksia); outline-offset: 2px; }
::selection { background: var(--fuksia-tume); color: var(--paber-hele); }

img, svg { max-width: 100%; }
.nahtamatu { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.vahele { position: absolute; left: .5rem; top: -4rem; z-index: 100; background: var(--paber-hele); color: var(--tint); padding: .5rem .9rem; border: 1px solid var(--tint); }
.vahele:focus { top: .5rem; }

/* ---------- lehe raam ---------- */
.leht { flex: 1 0 auto; width: 100%; max-width: var(--laius); margin: 0 auto; padding: 1.75rem var(--vahe) 3.5rem; }
.leht:focus { outline: none; }
body.vaade-tootaja { --laius: 80rem; --laius-pea: 80rem; }
.leht--kitsas { max-width: 36rem; }

/* ---------- päis ---------- */
.pea { border-bottom: 3px double var(--tint-pehme); background: linear-gradient(to bottom, rgb(248 241 220 / .55), transparent); }
.pea__sees {
  max-width: var(--laius-pea); margin: 0 auto; padding: 1rem var(--vahe) 0;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .5rem 2rem;
}
.pea__nimi { display: flex; flex-direction: column; text-decoration: none; color: var(--tint); line-height: 1; padding-bottom: .55rem; }
.pea__nimi:hover { color: var(--tint); }
.pea__kiri { font-family: var(--f-kiri); font-size: 1.35rem; color: var(--fuksia-tume); margin-bottom: .1rem; }
.pea__tiitel { font-family: var(--f-tahvel); font-size: 2rem; letter-spacing: .005em; }
.pea__nimi:hover .pea__tiitel { color: var(--fuksia-tume); }

.pea__menuu { display: flex; flex-direction: column-reverse; align-items: flex-end; gap: .35rem; }
.konto { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .25rem 1rem; font-size: .95rem; color: var(--hall); }
.konto form { margin: 0; display: inline; }
.konto__nimi { color: var(--tint); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keel { display: inline-flex; gap: .15rem; align-items: center; margin: 0; }
.keel button { all: unset; cursor: pointer; font: inherit; padding: 0 .35rem; color: var(--fuksia-tume); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
.keel button[aria-current="true"] { color: var(--tint); text-decoration: none; font-weight: 600; cursor: default; }
.keel button:focus-visible { outline: 2px solid var(--fuksia); outline-offset: 2px; }
.keel span { color: var(--joon); }

.menuu ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: stretch; gap: 0 .25rem; }
.menuu a, .menuu summary {
  display: block; padding: .45rem .85rem .5rem; font-family: var(--f-pealkiri); font-weight: 600; font-size: 1.2rem;
  color: var(--tint); text-decoration: none; border-bottom: 3px solid transparent; cursor: pointer; list-style: none;
}
.menuu summary::-webkit-details-marker { display: none; }
.menuu summary::after { content: ""; display: inline-block; width: .42em; height: .42em; margin-left: .45em; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-.15em) rotate(45deg); }
.menuu details[open] > summary::after { transform: translateY(.02em) rotate(-135deg); }
.menuu a:hover, .menuu summary:hover { color: var(--fuksia-tume); }
.menuu [aria-current] { color: var(--fuksia-tume); border-bottom-color: var(--fuksia); }
.menuu__alla { position: relative; }
.menuu__alla details > ul {
  position: absolute; right: 0; top: 100%; z-index: 30; min-width: 19rem; max-width: 92vw; flex-direction: column; gap: 0; padding: .35rem;
  background: var(--paber-hele); border: 1px solid var(--tint); box-shadow: 0 0 0 3px var(--paber), 0 0 0 4px var(--joon);
  margin-top: 5px;
}
.menuu__alla li a { border: 0; font-family: var(--f-tekst); font-weight: 400; font-size: 1.05rem; padding: .5rem .7rem; display: flex; gap: .6rem; align-items: baseline; }
.menuu__alla li a:hover { background: var(--paber-tume); }
.menuu__roll { margin-left: auto; font-size: .85rem; font-style: italic; color: var(--hall); }

.menuunupp { display: none; }

@media (max-width: 52rem) {
  .pea__sees { align-items: center; }
  .pea__tiitel { font-size: 1.5rem; }
  .pea__nimi { padding-bottom: .65rem; flex: 1 1 auto; min-width: 0; }
  .menuunupp {
    display: none; margin-left: auto; flex: none; align-items: center; gap: .5rem; cursor: pointer;
    font: 600 1.1rem/1 var(--f-pealkiri); color: var(--tint); background: var(--paber-hele); border: 1px solid var(--tint);
    padding: .55rem .9rem; box-shadow: 0 0 0 3px var(--paber), 0 0 0 4px var(--joon); margin-bottom: .5rem;
  }
  .js .menuunupp { display: inline-flex; }
  .menuunupp__riba, .menuunupp__riba::before, .menuunupp__riba::after { display: block; width: 1.1rem; height: 1.5px; background: currentColor; content: ""; position: relative; }
  .menuunupp__riba::before { position: absolute; top: -5px; }
  .menuunupp__riba::after { position: absolute; top: 5px; }
  .pea__menuu { flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: .5rem; }
  .js .pea__menuu { display: none; }
  .js .pea__menuu.on-lahti { display: flex; }
  .menuu ul { flex-direction: column; }
  .menuu a, .menuu summary { border-bottom: 1px dotted var(--joon-hele); border-left: 3px solid transparent; padding: .7rem .5rem; }
  .menuu [aria-current] { border-bottom-color: var(--joon-hele); border-left-color: var(--fuksia); }
  .menuu__alla details > ul { position: static; box-shadow: none; border: 0; border-left: 1px solid var(--joon); margin: 0 0 .5rem .5rem; min-width: 0; background: transparent; }
  .konto { justify-content: flex-start; padding: .5rem; border-top: 1px solid var(--joon-hele); }
}

/* ---------- muuseumi menüüriba ---------- */
.mriba { border-bottom: 1px solid var(--joon); background: rgb(232 217 176 / .35); }
.vaade-tootaja .mriba { background: var(--paber-tume); }
.mriba__sees { max-width: var(--laius-pea); margin: 0 auto; padding: .7rem var(--vahe) 0; }
.mriba__pea { display: flex; align-items: center; gap: .9rem; margin-bottom: .25rem; min-width: 0; }
.mriba__nimi { font-family: var(--f-pealkiri); font-weight: 600; font-size: 1.5rem; line-height: 1.15; color: var(--tint); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
a.mriba__nimi:hover { color: var(--fuksia-tume); }
.sakid { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--joon) transparent; -webkit-overflow-scrolling: touch; }
.sakid ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .15rem; white-space: nowrap; }
.sakid a { display: block; padding: .5rem .9rem .55rem; color: var(--tint); text-decoration: none; border-bottom: 3px solid transparent; font-size: 1.05rem; }
.sakid a:hover { color: var(--fuksia-tume); background: rgb(248 241 220 / .6); }
.sakid [aria-current] { color: var(--fuksia-tume); border-bottom-color: var(--fuksia); font-weight: 600; background: var(--paber-hele); }
.sakid .sakk--uus { margin-left: .6rem; }

/* ---------- jalus ---------- */
.jalus { border-top: 3px double var(--tint-pehme); margin-top: auto; padding: 1.25rem var(--vahe) 1.75rem; color: var(--hall); font-size: .95rem; }
.jalus__sees { max-width: var(--laius-pea); margin: 0 auto; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem 1.5rem; }
.jalus__nimi { font-family: var(--f-tahvel); font-size: 1.1rem; color: var(--tint-pehme); }
.jalus ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }

@media (prefers-reduced-motion: no-preference) {
  a, button, .nupp, summary { transition: color .15s ease, background-color .15s ease, border-color .15s ease; }
}

@media (max-width: 30rem) {
  .pea__tiitel { font-size: 1.3rem; }
  .pea__kiri { font-size: 1.15rem; }
  .menuunupp { padding: .5rem .7rem; }
  /* vihje, et sakid kerivad külgsuunas */
  .sakid { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.75rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 1.75rem), transparent); }
}
