/* components.css — reusable UI components (mobile-first; media queries live with each component) */

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--blue); --btn-fg: var(--white); --btn-border: var(--blue);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-5); border-radius: var(--r); border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg); font-weight: 600; font-size: var(--fs-sm); line-height: 1;
  text-decoration: none; white-space: nowrap; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.btn:hover { --btn-bg: var(--blue-hover); --btn-border: var(--blue-hover); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }
.btn--secondary { --btn-bg: var(--white); --btn-fg: var(--blue); --btn-border: var(--line-strong); }
.btn--secondary:hover { --btn-bg: var(--blue-50); --btn-border: var(--blue-100); --btn-fg: var(--blue); }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--blue); --btn-border: transparent; padding-inline: var(--s-3); }
.btn--ghost:hover { --btn-bg: var(--blue-50); --btn-border: transparent; --btn-fg: var(--blue); }
.btn--on-dark { --btn-bg: var(--white); --btn-fg: var(--blue); --btn-border: var(--white); }
.btn--on-dark:hover { --btn-bg: var(--blue-50); --btn-border: var(--blue-50); --btn-fg: var(--blue); }
.btn--danger { --btn-bg: var(--danger); --btn-border: var(--danger); }
.btn--danger:hover { --btn-bg: #8F1C13; --btn-border: #8F1C13; }
.btn--sm { min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn--icon { width: 44px; padding: 0; }
.btn--sm.btn--icon { width: 36px; }
.btn--block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; }

.link-arrow {
  display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 600; font-size: var(--fs-sm);
  color: var(--blue); text-decoration: none;
}
.link-arrow .icon { transition: transform var(--t-fast) var(--ease); }
.link-arrow:hover .icon { transform: translateX(3px); }

/* ---------- Chips / segmented ---------- */
.chips { display: flex; gap: var(--s-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 var(--s-4); border-radius: var(--r-pill); border: 1px solid var(--line-strong);
  background: var(--white); color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: var(--white); }
.chip:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- Form controls ---------- */
.field { display: grid; gap: var(--s-2); }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.field__hint { font-size: var(--fs-xs); color: var(--ink-3); }
.field__error { font-size: var(--fs-xs); color: var(--danger); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 0 var(--s-3); border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--white); color: var(--ink); font-size: var(--fs-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea { padding: var(--s-3); min-height: 120px; resize: vertical; line-height: 1.55; }
.select {
  appearance: none; padding-right: var(--s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23474B52' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 40px; }
.search__clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--r-sm); color: var(--ink-3); }
.search__clear:hover { background: var(--surface-3); color: var(--ink); }

/* ---------- Checkbox line ---------- */
.checkline { display: flex; gap: var(--s-2); align-items: flex-start; font-size: var(--fs-sm); color: var(--ink-2); }
.checkline input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--blue); flex: none; }

/* ---------- Badges & tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 var(--s-2); border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--ink-2);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge--plain::before { display: none; }
.badge--completed, .badge--published { background: var(--ok-bg); color: var(--ok); }
.badge--ongoing, .badge--pending { background: var(--warn-bg); color: var(--warn); }
.badge--planned { background: var(--violet-50); color: #4C4C8A; }
.badge--cancelled, .badge--archived { background: var(--surface-3); color: var(--ink-3); }
.badge--sample { background: var(--yellow-soft); color: #5C5A00; }
.badge--sample::before { display: none; }
.tag-cat { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.tag-cat__dot { width: 8px; height: 8px; border-radius: 2px; background: var(--cat, var(--blue)); }
.tag-cat__sub { font-weight: 500; color: var(--muted, #5B6475); } .tag-cat__sub::before { content: "·"; margin: 0 6px 0 2px; }
.year-chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 var(--s-2); border-radius: var(--r-sm);
  background: var(--blue); color: var(--white); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.02em;
}

/* ---------- Project card ---------- */
.cards { display: grid; gap: var(--s-6); grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  position: relative; display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.card:focus-within { box-shadow: var(--focus); }
.card__media { position: relative; aspect-ratio: 4 / 3; background: var(--surface-3); overflow: hidden; }
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform 600ms var(--ease), opacity var(--t-slow); }
.card:hover .card__media img { transform: scale(1.035); }
.card__media .year-chip { position: absolute; left: var(--s-3); top: var(--s-3); }
.card__media .badge--sample { position: absolute; right: var(--s-3); top: var(--s-3); }
.card__noimg { width: 100%; height: 100%; display: grid; place-items: center; color: var(--ink-3); background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--surface-3) 10px 20px); }
.card__body { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4) var(--s-5) var(--s-5); flex: 1; }
.card__title { font-size: var(--fs-md); line-height: var(--lh-snug); font-weight: 700; }
.card__title a { color: var(--ink); text-decoration: none; }
.card__title a::after { content: ''; position: absolute; inset: 0; } /* whole card clickable, one tab stop */
.card__title a:focus-visible { outline: none; }
.card__loc { display: flex; gap: var(--s-2); align-items: flex-start; color: var(--ink-2); font-size: var(--fs-sm); }
.card__loc .icon { margin-top: 2px; color: var(--blue); }
.card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); font-size: var(--fs-sm); color: var(--ink-2); margin-top: auto; padding-top: var(--s-3); border-top: 1px solid var(--line); }
.card__meta span { display: inline-flex; align-items: center; gap: 6px; }
.card__meta .icon { color: var(--ink-3); }
.card__meta .badge { margin-left: auto; }
.card__cta { color: var(--blue); font-weight: 600; font-size: var(--fs-sm); display: inline-flex; gap: 6px; align-items: center; }

/* Compact list item (map side panel) */
.mini {
  position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--s-3); align-items: center;
  padding: var(--s-3); border-radius: var(--r); transition: background var(--t-fast);
}
.mini:hover, .mini.is-active { background: var(--blue-50); }
.mini__img { width: 72px; height: 56px; border-radius: var(--r-sm); object-fit: cover; background: var(--surface-3); }
.mini__title { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); line-height: 1.3; }
.mini__title button, .mini__title a { text-align: left; color: inherit; text-decoration: none; }
.mini__title button::after, .mini__title a::after { content: ''; position: absolute; inset: 0; }
.mini__meta { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 2px; }

/* ---------- Skeleton ---------- */
.skel {
  position: relative; overflow: hidden; background: var(--surface-3); border-radius: var(--r-sm);
}
.skel::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }
.skel-line { height: 12px; margin-top: 10px; }
.skel-line--lg { height: 20px; }
.skel-line--w60 { width: 60%; } .skel-line--w40 { width: 40%; } .skel-line--w80 { width: 80%; }
.card--skeleton .card__media { aspect-ratio: 4 / 3; }

/* ---------- States ---------- */
.state {
  display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-12) var(--s-6); text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--r); color: var(--ink-2); background: var(--white);
}
.state .icon { color: var(--ink-3); }
.state__title { font-weight: 700; color: var(--ink); font-size: var(--fs-md); }
.state__text { font-size: var(--fs-sm); max-width: 44ch; }
.state--error .icon { color: var(--danger); }
.grid-span { grid-column: 1 / -1; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Notice banner (sample data) ---------- */
.notice {
  display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--gutter);
  background: var(--yellow-soft); color: #4A4800; font-size: var(--fs-sm); line-height: 1.5; border-bottom: 1px solid #E6E3A6;
}
.notice .icon { margin-top: 2px; }
.notice a { color: inherit; font-weight: 700; }
.notice__close { margin-left: auto; width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--r-sm); flex: none; }
.notice__close:hover { background: rgba(0, 0, 0, 0.06); }
.callout { display: flex; gap: var(--s-3); padding: var(--s-4); border-radius: var(--r); background: var(--yellow-soft); color: #4A4800; font-size: var(--fs-sm); line-height: 1.55; }
.callout--info { background: var(--blue-50); color: var(--blue-deep); }

/* ---------- Navbar ---------- */
.nav {
  position: sticky; top: 0; z-index: var(--z-nav); height: var(--nav-h); background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid transparent; transition: border-color var(--t), box-shadow var(--t);
}
@supports (backdrop-filter: blur(8px)) { .nav { background: rgba(255, 255, 255, 0.9); backdrop-filter: saturate(1.4) blur(8px); } }
.nav.is-scrolled { border-bottom-color: var(--line); }
.nav__inner { height: 100%; display: flex; align-items: center; gap: var(--s-6); }
.brand { display: inline-flex; align-items: center; gap: var(--s-3); text-decoration: none; color: var(--ink); }
.brand img { width: 40px; height: 40px; }
.brand__text { display: grid; line-height: 1.1; }
.brand__name { font-weight: 800; font-size: var(--fs-md); letter-spacing: 0.04em; color: var(--blue); }
.brand__sub { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; }
.nav__links { display: none; margin-left: auto; gap: var(--s-1); list-style: none; padding: 0; }
.nav__links a {
  display: inline-flex; align-items: center; height: 40px; padding: 0 var(--s-3); border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); text-decoration: none; position: relative;
}
.nav__links a:hover { color: var(--blue); background: var(--blue-50); }
.nav__links a[aria-current="true"] { color: var(--blue); }
.nav__links a[aria-current="true"]::after { content: ''; position: absolute; left: var(--s-3); right: var(--s-3); bottom: 4px; height: 2px; background: var(--yellow); }
.nav__toggle { margin-left: auto; }
@media (min-width: 1024px) {
  .nav__links { display: flex; }
  .nav__toggle { display: none; }
}

.drawer {
  position: fixed; inset: var(--nav-h) 0 auto 0; z-index: var(--z-nav); background: var(--white); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-3); padding: var(--s-3) var(--gutter) var(--s-6); transform-origin: top;
  animation: drawer-in var(--t) var(--ease);
}
.drawer ul { list-style: none; padding: 0; display: grid; }
.drawer a { display: flex; align-items: center; justify-content: space-between; min-height: 52px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; }
@keyframes drawer-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Breadcrumb ---------- */
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; padding: 0; font-size: var(--fs-sm); color: var(--ink-3); }
.breadcrumb li + li::before { content: '/'; margin-right: var(--s-2); color: var(--line-strong); }
.breadcrumb a { color: var(--ink-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--blue); text-decoration: underline; }

/* ---------- Avatar ---------- */
.avatar {
  --av: 44px; width: var(--av); height: var(--av); border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 700; font-size: calc(var(--av) * 0.36); letter-spacing: 0.02em;
  background: var(--av-bg, var(--blue-50)); color: var(--av-fg, var(--blue));
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Footer ---------- */
.footer { background: var(--blue-deep); color: #C9D5E6; padding-block: var(--s-16) var(--s-8); font-size: var(--fs-sm); }
.footer a { color: #E6EDF7; text-decoration: none; }
.footer a:hover { color: var(--white); text-decoration: underline; }
.footer .muted { color: #9FB1CB; }
.footer__grid { display: grid; gap: var(--s-10); }
@media (min-width: 768px) { .footer__grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.footer__brand { display: flex; gap: var(--s-4); align-items: flex-start; }
.footer__brand img { width: 56px; height: 56px; background: var(--white); border-radius: 50%; padding: 2px; }
.footer__title { color: var(--white); font-weight: 700; font-size: var(--fs-sm); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: var(--s-4); }
.footer ul { list-style: none; padding: 0; display: grid; gap: var(--s-3); }
.footer li { display: flex; gap: var(--s-2); align-items: flex-start; }
.footer li .icon { margin-top: 2px; color: var(--yellow); }
.footer__bottom { margin-top: var(--s-12); padding-top: var(--s-6); border-top: 1px solid rgba(255, 255, 255, 0.12); display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-6); justify-content: space-between; color: #9FB1CB; font-size: var(--fs-xs); }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: var(--z-toast); left: 50%; bottom: var(--s-6); transform: translateX(-50%); display: grid; gap: var(--s-2); width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r);
  background: var(--ink); color: var(--white); box-shadow: var(--shadow-3); font-size: var(--fs-sm); line-height: 1.45;
  animation: toast-in var(--t) var(--ease);
}
.toast--success .icon { color: #8FD3AC; }
.toast--error { background: #5B130D; }
.toast--error .icon { color: #FFB4AB; }
.toast__action { margin-left: auto; font-weight: 700; color: var(--yellow); white-space: nowrap; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity var(--t), transform var(--t); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Dialog (modal / lightbox) ---------- */
.modal {
  width: min(520px, calc(100vw - 32px)); border-radius: var(--r-lg); background: var(--white); color: var(--ink);
  box-shadow: var(--shadow-3); padding: 0; margin: auto;
}
.modal::backdrop { background: rgba(14, 44, 82, 0.45); }
.modal[open] { animation: modal-in var(--t) var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal__body { padding: var(--s-6); display: grid; gap: var(--s-3); }
.modal__title { font-size: var(--fs-lg); }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.modal--wide { width: min(880px, calc(100vw - 32px)); }

.lightbox {
  width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; background: rgba(12, 18, 28, 0.96); color: var(--white);
}
.lightbox::backdrop { background: rgba(12, 18, 28, 0.96); }
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: fade-in var(--t) var(--ease); }
@keyframes fade-in { from { opacity: 0; } }
.lightbox__bar { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); color: #C7CFDB; }
.lightbox__bar .btn--icon { color: var(--white); }
.lightbox__stage { position: relative; display: grid; place-items: center; padding: 0 var(--s-2); touch-action: pan-y; }
.lightbox__img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); user-select: none; opacity: 0; transition: opacity var(--t) var(--ease); }
.lightbox__img.is-loaded { opacity: 1; }
.lightbox__spacer { flex: 1; }
.lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.12); color: var(--white); }
.lightbox__nav:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox__nav--prev { left: var(--s-3); } .lightbox__nav--next { right: var(--s-3); }
.lightbox__caption { padding: var(--s-4) var(--s-4) var(--s-6); text-align: center; font-size: var(--fs-sm); color: #DCE3EC; display: grid; gap: var(--s-2); justify-items: center; }
.lightbox__caption a { color: var(--yellow); font-weight: 600; }
.lightbox .spinner { position: absolute; color: var(--white); }
.icon-btn-light { color: var(--white); }
.icon-btn-light:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- Bottom sheet (mobile map detail) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: var(--z-sheet); background: rgba(14, 44, 82, 0.35); animation: fade-in var(--t) var(--ease); }
.sheet {
  position: fixed; z-index: calc(var(--z-sheet) + 1); left: 0; right: 0; bottom: 0; max-height: 85dvh; overflow-y: auto;
  background: var(--white); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-3); padding: 0 var(--gutter) calc(var(--s-6) + env(safe-area-inset-bottom));
  transform: translateY(0); transition: transform var(--t) var(--ease); animation: sheet-in var(--t) var(--ease);
}
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet__handle { position: sticky; top: 0; display: grid; place-items: center; height: 28px; background: var(--white); cursor: grab; touch-action: none; }
.sheet__handle::before { content: ''; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.sheet.is-dragging { transition: none; }
