/* Karala Gallery — shared tokens and primitives.
   Viewing grey is neutral on purpose: a tinted surround shifts how colour reads in a photograph.
   The china-marker red (--grease) is reserved for selection marks. */

@font-face {
  font-family: "Finlandica";
  src: url("../fonts/finlandica-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  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: "Finlandica";
  src: url("../fonts/finlandica-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, 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: "Finlandica";
  src: url("../fonts/finlandica-latin-wght-italic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
  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;
}

:root {
  --viewing: #242423;
  --panel: #2d2d2b;
  --raised: #373735;
  --rule: #464643;
  --fog: #a6a49e;
  --paper: #ecebe6;
  --grease: #d8463a;
  --alert: #e3a95f;
  --on-paper: #1c1c1b;
  --shadow: rgba(0, 0, 0, 0.38);
  --font: "Finlandica", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --r: 3px;
  color-scheme: dark;
}
[data-theme="light"] {
  --viewing: #f3f2ee;
  --panel: #ffffff;
  --raised: #e8e7e2;
  --rule: #d4d2cb;
  --fog: #66645e;
  --paper: #1e1e1d;
  --grease: #c3342a;
  --alert: #985808;
  --on-paper: #f7f6f2;
  --shadow: rgba(30, 30, 28, 0.16);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100% }
body {
  margin: 0;
  background: var(--viewing);
  color: var(--paper);
  font: 400 16px/1.5 var(--font);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video { display: block; max-width: 100% }
a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 1px }
a:hover { text-decoration-thickness: 2px }
p { margin: 0 0 1em }
button { font: inherit; color: inherit }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.875em; background: var(--panel); padding: 0.1em 0.35em; border-radius: 2px; word-break: break-all }
hr { border: 0; border-top: 1px solid var(--rule) }

:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0 }
.skip { position: absolute; left: 12px; top: -60px; z-index: 1000; background: var(--paper); color: var(--on-paper); padding: 10px 14px; border-radius: var(--r) }
.skip:focus { top: 12px }
[hidden] { display: none !important }

/* Type scale: 12 14 16 18 21 24 36 48 60 72 */
.h1 { font-size: 36px; line-height: 1.1; font-weight: 500; letter-spacing: -0.015em; margin: 0 }
.h2 { font-size: 24px; line-height: 1.2; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 16px }
.h3 { font-size: 21px; line-height: 1.25; font-weight: 500; margin: 0 0 12px }
.h4 { font-size: 16px; line-height: 1.35; font-weight: 600; margin: 0 0 8px }
.muted { color: var(--fog) }
.lede { font-size: 18px; color: var(--fog); max-width: 60ch }
.count { font-size: 14px; color: var(--fog); font-weight: 400 }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45em;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: var(--r);
  background: transparent; color: var(--paper);
  font: 500 14px/1 var(--font); letter-spacing: 0.005em;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s, color 0.12s;
}
.btn:hover { border-color: var(--fog); text-decoration: none }
.btn-primary { background: var(--paper); border-color: var(--paper); color: var(--on-paper) }
.btn-primary:hover { background: #ffffff; border-color: #ffffff }
[data-theme="light"] .btn-primary:hover { background: #000; border-color: #000 }
.btn-quiet { border-color: transparent }
.btn-quiet:hover { border-color: var(--rule) }
.btn-danger { color: var(--alert); border-color: var(--alert) }
.btn-small { min-height: 32px; padding: 0 10px }
.btn-wide { width: 100% }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed }
.link-btn { background: none; border: 0; padding: 0; color: var(--paper); text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; font: inherit }
.link-btn:hover { text-decoration-thickness: 2px }
label.link-btn { display: inline; margin: 0; font: inherit; color: var(--paper) }

/* Forms */
label, legend { display: block; font: 500 14px/1.35 var(--font); color: var(--paper); margin: 0 0 6px; padding: 0 }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0 }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input[type="url"], input[type="search"], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  background: var(--panel); color: var(--paper);
  border: 1px solid var(--rule); border-radius: var(--r);
  font: 400 16px/1.4 var(--font);
  appearance: none; -webkit-appearance: none;
}
select {
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--fog) 50%), linear-gradient(135deg, var(--fog) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
textarea { resize: vertical; min-height: 84px }
input:focus, select:focus, textarea:focus { border-color: var(--fog) }
input[readonly] { color: var(--fog) }
input[type="checkbox"], input[type="radio"] { accent-color: var(--paper); width: 18px; height: 18px; margin: 0; flex: none }
input[type="range"] { width: 100%; accent-color: var(--paper) }
input[type="file"] { font-size: 14px; color: var(--fog) }
.field { margin: 0 }
.help { font-size: 14px; line-height: 1.45; color: var(--fog); margin: 6px 0 0; max-width: 68ch }
.form-error { color: var(--alert); font-size: 14px; margin: 8px 0 0 }
.form-error p { margin: 0 0 4px }
.stack > * + * { margin-top: 16px }
.grid-2, .grid-3 { display: grid; gap: 16px 20px; grid-template-columns: repeat(2, minmax(0, 1fr)) }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr } }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 16px; line-height: 1.4; margin: 12px 0 0; cursor: pointer }
.check-row input { margin-top: 1px }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 500; max-width: min(520px, calc(100% - 32px));
  background: var(--paper); color: var(--on-paper);
  padding: 11px 16px; border-radius: var(--r);
  font-size: 14px; font-weight: 500; box-shadow: 0 10px 30px var(--shadow);
}
.toast.is-error { background: var(--alert); color: #1c1c1b }

/* Flash messages */
.flashes { margin: 0 0 24px }
.flash { margin: 0 0 8px; padding: 10px 14px; border-left: 2px solid var(--paper); background: var(--panel); font-size: 14px }
.flash-error { border-left-color: var(--alert) }

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