/* Perinnekasvit: shared components. Views add their own css/views/<name>.css */

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: .5rem; top: -4rem; z-index: 200;
  background: #fff; color: var(--green-deep); padding: .75rem 1rem; border-radius: var(--radius);
  font-weight: 600; box-shadow: var(--shadow); transition: top .15s;
}
.skip-link:focus { top: .5rem; }

/* ---------- header ---------- */
.site-header { background: var(--header-bg); color: var(--header-text); position: relative; z-index: 50; }
.site-header a { color: var(--header-text); }
.site-header__bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding-block: .75rem; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; min-height: var(--tap); flex: 1 1 auto; }
.brand:hover { color: #fff; }
.brand__logo { height: 58px; width: auto; flex: none; display: block; }

.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__name { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; }
.brand__sub { font-size: .85rem; opacity: .8; }
.header-search { position: relative; flex: 1 1 100%; order: 3; max-width: 26rem; }
.header-search input {
  width: 100%; min-height: var(--tap); border-radius: 999px; border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .1); color: #fff; padding: 0 3rem 0 2.75rem; font-size: 1rem;
}
.header-search input::placeholder { color: rgba(255, 255, 255, .7); }
.header-search input:focus { background: #fff; color: #14261d; }
.header-search input:focus::placeholder { color: #5b6b62; }
.header-search__icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); pointer-events: none; opacity: .8; }
.header-search input:focus ~ .header-search__icon { color: #14261d; }
.header-search__hint {
  position: absolute; right: .9rem; top: 50%; transform: translateY(-50%);
  font: 600 .8rem var(--font-body); border: 1px solid rgba(255, 255, 255, .35); border-radius: 4px; padding: 0 .4rem; opacity: .75; pointer-events: none;
}
.header-search input:focus ~ .header-search__hint { display: none; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--tap); height: var(--tap); padding: 0;
  border-radius: 50%; background: transparent; color: var(--header-text); border: 1px solid rgba(255, 255, 255, .35); cursor: pointer;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .14); }
.theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__sun { display: block; }
:root[data-theme="dark"] .theme-toggle__moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle__moon { display: none; }
}
.menu-toggle {
  display: inline-flex; align-items: center; gap: .5rem; min-height: var(--tap); padding: 0 1rem;
  background: transparent; color: var(--header-text); border: 1px solid rgba(255, 255, 255, .35); border-radius: var(--radius); cursor: pointer;
}
.menu-toggle[aria-expanded="true"] { background: rgba(255, 255, 255, .12); }
.site-nav { background: rgba(0, 0, 0, .18); border-top: 1px solid rgba(255, 255, 255, .08); display: none; }
.site-nav.is-open { display: block; }
.site-nav__list { list-style: none; margin-block: 0; padding-block: .5rem; display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; }
.site-nav__list a {
  display: flex; align-items: center; min-height: var(--tap); padding: 0 .75rem; text-decoration: none;
  border-radius: var(--radius); border-bottom: 3px solid transparent; font-weight: 600;
}
.site-nav__list a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.site-nav__list a[aria-current="page"] { background: rgba(255, 255, 255, .12); border-bottom-color: var(--gold); }

@media (min-width: 62rem) {
  .menu-toggle { display: none; }
  .header-search { flex: 0 1 20rem; order: 0; }
  .site-nav { display: block; background: transparent; border: 0; }
  .site-header__bar { padding-bottom: .25rem; }
  .site-nav__list { display: flex; flex-wrap: wrap; gap: .25rem; padding-block: 0 .5rem; }
  .site-nav__list a { border-radius: 8px 8px 0 0; padding: 0 1rem; }
}

/* ---------- footer ---------- */
.site-footer { background: var(--footer-bg); color: var(--footer-text); margin-top: 4rem; padding-block: 2.5rem; font-size: .95rem; }
.site-footer a { color: #fff; }
.site-footer__grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.site-footer__title { font-size: 1.05rem; color: #fff; margin: 0 0 .5rem; }
.site-footer__links { list-style: none; padding: 0; margin: 0; }
.site-footer__links a { display: inline-block; padding-block: .3rem; }
.site-footer p { margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--tap);
  padding: .5rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); text-decoration: none; font-weight: 600; cursor: pointer; line-height: 1.2; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn--primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-mid); border-color: var(--green-mid); color: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn--primary { background: #74c69d; border-color: #74c69d; color: #0d1a13; }
  :root:not([data-theme="light"]) .btn--primary:hover { background: #95d8b5; border-color: #95d8b5; color: #0d1a13; }
}
:root[data-theme="dark"] .btn--primary { background: #74c69d; border-color: #74c69d; color: #0d1a13; }
:root[data-theme="dark"] .btn--primary:hover { background: #95d8b5; border-color: #95d8b5; color: #0d1a13; }
.btn--ghost { background: transparent; }
.btn--small { min-height: var(--tap); font-size: .95rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ---------- chips, badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .4rem; min-height: var(--tap); padding: 0 1rem;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: .98rem; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; line-height: 1.2;
}
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip[aria-pressed="true"], .chip[aria-current="true"] { background: var(--green); border-color: var(--green); color: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip[aria-pressed="true"], :root:not([data-theme="light"]) .chip[aria-current="true"] { background: #74c69d; border-color: #74c69d; color: #0d1a13; }
}
:root[data-theme="dark"] .chip[aria-pressed="true"], :root[data-theme="dark"] .chip[aria-current="true"] { background: #74c69d; border-color: #74c69d; color: #0d1a13; }
.chip__count { font-weight: 400; opacity: .8; font-size: .9em; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0; list-style: none; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .6rem; border-radius: 999px;
  background: var(--surface-3); color: var(--text); font-size: .82rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.badge--heritage { background: var(--cream); color: var(--green); border: 1px solid #d4a01788; }
.badge--heritage .icon { color: #8a6a12; }
.badge--muted { background: transparent; border: 1px solid var(--border); color: var(--text-muted); font-weight: 400; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge--heritage { background: #2a3626; color: #f1e3b0; border-color: #d4a01799; }
  :root:not([data-theme="light"]) .badge--heritage .icon { color: var(--gold); }
}
:root[data-theme="dark"] .badge--heritage { background: #2a3626; color: #f1e3b0; border-color: #d4a01799; }
:root[data-theme="dark"] .badge--heritage .icon { color: var(--gold); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border); padding: 1.25rem; position: relative;
}
.card--flush { padding: 0; overflow: hidden; }
.card--link { transition: box-shadow .2s, transform .2s, border-color .2s; }
.card--link:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-2px); }
.card--link a.card__link { text-decoration: none; color: inherit; }
.card--link a.card__link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); } /* whole card clickable */
.card--link a.card__link:focus-visible { outline: none; }
.card--link:has(a.card__link:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.card__title { font-family: var(--font-head); font-size: 1.25rem; margin: 0 0 .25rem; color: var(--heading); }
.card__meta { color: var(--text-muted); font-size: .92rem; margin: 0; }
.card--mint { background: var(--surface-3); }
.card--cream { background: var(--surface-2); }

/* ---------- bars ---------- */
.bar { display: block; height: .55rem; border-radius: 999px; background: var(--bar-track); overflow: hidden; min-width: 3rem; }
.bar__fill { display: block; height: 100%; border-radius: inherit; background: var(--bar-fill); transition: width .5s ease-out; }
.bar--thick { height: .85rem; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > label, .field-label { font-weight: 600; font-size: .95rem; }
.input, .select, .field input[type="search"], .field input[type="text"], .field select {
  min-height: var(--tap); padding: .4rem .9rem; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); width: 100%;
}
.select, .field select { appearance: auto; padding-right: .6rem; }
.input:focus-visible, .select:focus-visible { outline-offset: 0; }
.switch { display: inline-flex; align-items: center; gap: .6rem; min-height: var(--tap); cursor: pointer; font-weight: 600; }
.switch input { width: 1.4rem; height: 1.4rem; accent-color: var(--green-mid); margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; margin-bottom: 1.25rem; }
.toolbar .field { min-width: 11rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.table caption { text-align: left; padding: .75rem 1rem; font-weight: 600; color: var(--text-muted); caption-side: top; }
.table th, .table td { padding: .6rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { background: var(--surface-3); color: var(--heading); font-weight: 700; position: sticky; top: 0; }
.table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bar-track) 25%, var(--surface-3) 50%, var(--bar-track) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 6px; height: 1.1rem; margin-bottom: .8rem;
}
.skeleton--title { height: 2.6rem; width: 55%; margin-bottom: 1.4rem; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- empty / error ---------- */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-state__title { font-family: var(--font-head); font-size: 1.25rem; color: var(--heading); margin-bottom: .25rem; }
.error-panel { max-width: 40rem; margin: 3rem auto; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border-strong); border-left: 6px solid #b4573c; border-radius: var(--radius); }

/* ---------- icons ---------- */
.icon { flex: none; }
.icon-circle { display: inline-grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%; background: var(--surface-3); color: var(--accent); }

/* ---------- combobox (instant search results) ---------- */
.combo { position: relative; }
.combo__list {
  position: absolute; left: 0; right: 0; top: calc(100% + .35rem); z-index: 100; margin: 0; padding: .35rem; list-style: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: min(26rem, 70vh); overflow-y: auto; text-align: left;
}
.combo__opt {
  display: flex; align-items: center; gap: .75rem; min-height: var(--tap); padding: .35rem .75rem; border-radius: 6px; cursor: pointer; line-height: 1.3;
}
.combo__opt[aria-selected="true"], .combo__opt:hover { background: var(--surface-3); }
.combo__opt .icon { color: var(--accent); }
.combo__text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.combo__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.combo__sub { font-size: .85rem; color: var(--text-muted); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo__kind { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.combo__empty { padding: .8rem 1rem; color: var(--text-muted); }

/* ---------- lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 16, 11, .95); color: #f3efe2; display: grid; grid-template-rows: auto 1fr auto; }
.lb__top { display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem; gap: 1rem; }
.lb__counter { font-variant-numeric: tabular-nums; opacity: .85; }
.lb__tools { display: flex; gap: .25rem; }
.lb__btn {
  width: var(--tap); height: var(--tap); display: inline-grid; place-items: center; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer;
}
.lb__btn:hover { background: rgba(255, 255, 255, .2); }
.lb__stage { position: relative; overflow: hidden; touch-action: none; display: grid; place-items: center; min-height: 0; cursor: zoom-in; }
.lb__stage.is-zoomed { cursor: grab; }
.lb__img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; user-select: none; -webkit-user-drag: none; transition: opacity .2s; will-change: transform; }
.lb__img.is-loading { opacity: .7; filter: blur(2px); }
.lb__btn--prev, .lb__btn--next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 3.25rem; height: 3.25rem; background: rgba(0, 0, 0, .45); }
.lb__btn--prev { left: .5rem; }
.lb__btn--next { right: .5rem; }
.lb__caption { padding: .75rem 1rem 1.1rem; text-align: center; display: flex; flex-direction: column; gap: .15rem; align-items: center; max-width: 48rem; margin-inline: auto; font-size: .98rem; }
.lb__title { font-family: var(--font-head); font-size: 1.15rem; }
.lb__text { opacity: .85; }
.lb__link { color: #fff; display: inline-flex; align-items: center; gap: .35rem; min-height: var(--tap); }

/* ---------- misc ---------- */
.kbd, kbd { font-family: var(--font-body); }
hr { border: 0; border-top: 1px solid var(--border); margin-block: 2rem; }
.figure-img { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.sr-live { position: absolute; left: -9999px; }

/* Back-to-top: 52 px green circle, arrow centred (matches the association website) */
.to-top { position: fixed; right: 1rem; bottom: 1.25rem; z-index: 70; width: 52px; height: 52px; padding: 0; border-radius: 50%; border: 2px solid rgba(245, 239, 224, .9); background: var(--green, #1b4332); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 14px rgba(20, 38, 29, .35); transition: transform .18s ease, background-color .18s ease; }
.to-top[hidden] { display: none; }
.to-top:hover { background: #2d6a4f; transform: translateY(-3px); }
.to-top:focus-visible { outline: 3px solid var(--accent, #d4a017); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .to-top { transition: none; } .to-top:hover { transform: none; } }
@media print { .to-top { display: none !important; } }
