/*
 * Shared tokens and base styles. Every file in this folder is loaded on every
 * page, so page-specific styles are scoped under body.site or body.admin.
 */

:root {
  --color-bg: #fbfaf8;
  --color-surface: #ffffff;
  --color-text: #1d1d1f;
  --color-muted: #6e6e73;
  --color-border: #e3e1dc;
  --color-accent: #2f6f4f;
  --color-accent-text: #ffffff;
  --color-danger: #b42318;
  --color-draft: #8a6d1f;
  --color-scheduled: #2a5db0;

  --font-body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-reading: Charter, "Iowan Old Style", Georgia, serif;

  --radius: 6px;
  --content-width: 42rem;

  --lexxy-text-size: 1.125rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #161615;
    --color-surface: #1f1f1e;
    --color-text: #ecebe8;
    --color-muted: #9e9d99;
    --color-border: #34332f;
    --color-accent: #6fbf94;
    --color-accent-text: #10241a;
    --color-danger: #f97066;
    --color-draft: #e0b84f;
    --color-scheduled: #84adf0;

    /* Lexxy's grey scale assumes dark text on a light page, so flip it for dark mode */
    --lexxy-color-ink: oklch(93% 0 0);
    --lexxy-color-ink-medium: oklch(78% 0 0);
    --lexxy-color-ink-light: oklch(62% 0 0);
    --lexxy-color-ink-lighter: oklch(38% 0 0);
    --lexxy-color-ink-lightest: oklch(26% 0 0);
    --lexxy-color-ink-inverted: var(--color-surface);
    --lexxy-color-accent-light: oklch(35% 0.06 254);
    --lexxy-color-accent-lightest: oklch(30% 0.05 254);
    --lexxy-color-code-token-punctuation: var(--lexxy-color-ink);
  }
}

:root {
  --lexxy-color-link: var(--color-accent);
}

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-accent); }

img { max-width: 100%; height: auto; }

/* Forms and buttons (shared by sign-in and admin) */

.field { margin-bottom: 1.25rem; }

.field > label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: inherit;
  font: inherit;
}

.input:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }

.hint { margin: 0.35rem 0 0; color: var(--color-muted); font-size: 0.85rem; }

.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button-secondary { background: transparent; color: var(--color-accent); }

.button-danger {
  border-color: var(--color-danger);
  background: transparent;
  color: var(--color-danger);
}

.button-danger-solid {
  border-color: var(--color-danger);
  background: var(--color-danger);
  color: #fff;
}

/* In-page "are you sure?" for delete buttons (see confirm_dialog.js) */
.confirm-dialog {
  max-width: min(26rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) * 2);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.25);
}

.confirm-dialog::backdrop { background: rgb(0 0 0 / 0.45); }

.confirm-dialog p { margin: 0 0 1.25rem; line-height: 1.45; }

.confirm-dialog-actions { display: flex; justify-content: flex-end; gap: 0.75rem; }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.flash {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  margin: 0 0 1.25rem;
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
}

.flash-alert { background: color-mix(in srgb, var(--color-danger) 12%, transparent); }

.empty { color: var(--color-muted); }

/* Public site */

/* The footer sits at the bottom of the window when a page is short */
body.site {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

body.site > * { width: 100%; }

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.site-name { color: var(--color-text); font-weight: 700; text-decoration: none; }

.site-header nav { display: flex; gap: 1rem; }

.site-main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
  flex: 1 0 auto;
}

.page-title { font-size: 2rem; margin: 0 0 1.5rem; }

.post-list { list-style: none; margin: 0; padding: 0; }

.post-list-item { padding: 1.25rem 0; border-top: 1px solid var(--color-border); }

.post-list-item time { color: var(--color-muted); font-size: 0.85rem; }

.post-list-item h2 { margin: 0.2rem 0 0.4rem; font-size: 1.35rem; }

.post-list-item h2 a { color: var(--color-text); text-decoration: none; }

.post-list-item h2 a:hover { color: var(--color-accent); }

.post-list-item p { margin: 0; color: var(--color-muted); }

.post-header { margin-bottom: 2rem; }

.post-header h1 { font-size: clamp(2rem, 5vw, 2.75rem); line-height: 1.15; margin: 0 0 0.5rem; }

.post-header time { color: var(--color-muted); }

.admin-edit-link { margin: 1rem 0 0; }

.admin-edit-link .button { padding: 0.3rem 0.9rem; font-size: 0.9rem; }

.post-cover { display: block; width: 100%; border-radius: var(--radius); margin-bottom: 2rem; }

.post-body { font-family: var(--font-reading); }

.preview-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--color-draft);
  color: #fff;
  font-weight: 600;
  text-align: center;
}

.preview-banner a { color: inherit; margin-left: 1rem; }

.sign-in { max-width: 24rem; margin: 3rem auto; }

.trip-meta { margin: 0.25rem 0 0; color: var(--color-muted); }

.stars { color: var(--color-draft); letter-spacing: 0.05em; }

.trip-list-crags { font-size: 0.9rem; }

.feed-kind { margin: 0; color: var(--color-muted); font-size: 0.85rem; }

.site-header nav { align-items: baseline; }

.header-search .input { width: 9rem; padding: 0.25rem 0.6rem; font-size: 0.9rem; }

/* Header menus (public and admin). Wide screens show the links in a row. On
   narrow ones, once menu_controller.js has loaded (.menu-ready), the links fold
   into a dropdown behind a Menu button; without JavaScript they stay visible. */
.site-header, .admin-header { position: relative; }

.menu-button { display: none; }

@media (max-width: 600px) {
  .menu-ready { align-items: center; }

  .menu-ready .menu-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
  }

  .menu-icon, .menu-icon::before, .menu-icon::after {
    display: block;
    width: 1rem;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
  }
  .menu-icon { position: relative; }
  .menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
  .menu-icon::before { top: -5px; }
  .menu-icon::after { top: 5px; }

  .menu-ready .menu-panel { display: none; }

  .menu-ready.menu-open .menu-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 1rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    box-shadow: 0 12px 24px rgb(0 0 0 / 0.15);
  }

  .menu-ready.menu-open .menu-panel > a,
  .menu-ready.menu-open .menu-panel > form > .link-button {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 1.05rem;
  }

  .menu-ready.menu-open .menu-panel > form { display: block; }

  .menu-ready.menu-open .menu-panel > form > .link-button { width: 100%; text-align: left; }

  .menu-ready.menu-open .menu-panel > :last-child,
  .menu-ready.menu-open .menu-panel > form:last-child > .link-button { border-bottom: 0; }

  .menu-ready.menu-open .header-search { padding-top: 0.75rem; }
  .menu-ready.menu-open .header-search .input { width: 100%; padding: 0.55rem 0.7rem; font-size: 1rem; }

  /* Without JavaScript, keep the row of links from overflowing */
  .site-header:not(.menu-ready) nav, .admin-header:not(.menu-ready) nav { flex-wrap: wrap; }
}

/* Footer */

.site-footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.9rem;
}

.site-footer p { margin: 0 0 0.5rem; }

.site-footer ul { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; list-style: none; margin: 0; padding: 0; }

.site-footer a { color: var(--color-muted); }

.site-footer a:hover { color: var(--color-accent); }

.search-form { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }

.search-summary { color: var(--color-muted); }

.search-snippet { color: var(--color-muted); }

.search-snippet mark {
  padding: 0 0.1em;
  border-radius: 3px;
  background: color-mix(in srgb, var(--color-draft) 30%, transparent);
  color: var(--color-text);
}

.more-links { margin-top: 2rem; color: var(--color-muted); }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; margin: 2rem 0 0; padding: 0; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.tag:hover { border-color: var(--color-accent); color: var(--color-accent); }

.contact-form { max-width: 32rem; margin-top: 1.5rem; }

/* Read by screen readers, not shown */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.subscribe-form { display: flex; flex-wrap: wrap; gap: 0.5rem; max-width: 28rem; }

.subscribe-form .input { flex: 1 1 14rem; width: auto; }

/* In the footer, a single compact line: label, field and button */
.footer-subscribe { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 1.25rem; }

.site-footer .footer-subscribe p { margin: 0; }

.site-footer .subscribe-form { flex-wrap: nowrap; gap: 0.4rem; }

.site-footer .subscribe-form .input { flex: 0 1 13rem; padding: 0.25rem 0.6rem; font-size: 0.9rem; }

.site-footer .subscribe-form .button {
  padding: 0.25rem 0.75rem;
  background: transparent;
  color: var(--color-accent);
  font-size: 0.85rem;
}

.subscription-form { margin: 1rem 0 1.5rem; }

.subscription-form .button { margin-top: 0.5rem; }

.subscription-hint { margin-bottom: 0.75rem; }

.checkbox { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }

/* The honeypot: moved off-screen rather than display:none, which some bots skip */
.contact-website { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.like { margin-top: 1.5rem; }

.like-form { display: inline; }

.like-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  cursor: pointer;
}

.like-button:hover { border-color: var(--color-danger); color: var(--color-danger); }

.like-button[aria-pressed="true"] { border-color: var(--color-danger); color: var(--color-danger); }

.like-heart { font-size: 1.15rem; line-height: 1; }

.climbs { margin-top: 3rem; }

.climbs > h2 { font-size: 1.25rem; margin: 0 0 1rem; }

.climb { padding: 1rem 0; border-top: 1px solid var(--color-border); }

.climb h3 { margin: 0; font-size: 1.1rem; }

.climb-grade { margin-left: 0.4rem; color: var(--color-muted); font-weight: 500; }

.climb-meta { margin: 0.2rem 0 0.5rem; color: var(--color-muted); font-size: 0.9rem; }

.climb-pitch { margin: 0; }

.climb-pitches { list-style: none; margin: 0; padding: 0; }

.climb-pitches li { padding: 0.15rem 0; }

.climb-pitch-number { display: inline-block; width: 2rem; font-weight: 600; }

.climb-pitch-grade { display: inline-block; min-width: 3.5rem; color: var(--color-muted); }

.gallery { margin-top: 3rem; }

.gallery h2 { font-size: 1.25rem; margin: 0 0 1rem; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.5rem;
}

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
}

/* Photo viewer: always dark, whatever the page's color scheme */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 3.5rem 1rem 4.5rem;
  border: 0;
  background: transparent;
  color: #fff;
}

.lightbox[open] { display: flex; align-items: center; justify-content: center; }

.lightbox::backdrop { background: rgb(0 0 0 / 0.9); }

.lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
}

.lightbox-image {
  max-width: 100%;
  min-height: 0;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
}

.lightbox-text { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; max-width: 40rem; text-align: center; line-height: 1.4; }

.lightbox-caption { color: rgb(255 255 255 / 0.9); }

.lightbox-details { color: rgb(255 255 255 / 0.65); font-size: 0.9rem; }

.lightbox-trip-link { color: #9fd8b8; font-size: 0.9rem; }

.lightbox-text > [hidden] { display: none; }

/* Gallery page */

.gallery-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; margin-bottom: 1.5rem; }

.gallery-filters label { display: flex; flex-direction: column; gap: 0.3rem; flex: 1 1 12rem; }

.gallery-filters label span { font-size: 0.85rem; font-weight: 600; }

.gallery-reset { padding-bottom: 0.55rem; font-size: 0.9rem; }

/* Batches that load as you scroll sit inside frames; let their photos join the grid */
.gallery-grid turbo-frame { display: contents; }

.gallery-loading { grid-column: 1 / -1; color: var(--color-muted); text-align: center; }

.lightbox-controls {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lightbox-counter { min-width: 4.5rem; text-align: center; font-size: 0.9rem; }

.lightbox-button {
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.15);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-button:hover:not(:disabled) { background: rgb(255 255 255 / 0.3); }

.lightbox-button:disabled { opacity: 0.3; cursor: default; }

.lightbox-close { position: absolute; top: 0.75rem; right: 0.75rem; }
