/* Shared public-site shell. Admin pages do not load this file. */
:root {
  --paper: #eeeae1;
  --paper-light: #f8f6f0;
  --paper-deep: #e2ddd1;
  --ink: #262824;
  --muted: var(--brown-muted);
  --faint: #756b62;
  --line: #d7d2c7;
  --line-strong: #c8c1b4;
  --brown: #8a4e37;
  --brown-dark: #693b2c;
  --brown-soft: #e6d3c6;
  --brown-wash: #f1e9e1;
  --brown-muted: #6d6258;
  /* The base stylesheet uses this legacy token for status dots. */
  --green: var(--brown);
  --accent: #d3a75c;
  --content-pad: clamp(20px, 4.8vw, 60px);
  --body-size: 16px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: var(--sans);
  --callsign: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html { color-scheme: light; scroll-behavior: smooth; }

body:not(.admin-body) {
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font: var(--body-size)/1.72 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font-family: var(--sans); }

.site-frame:not(.admin-frame) {
  display: flex;
  width: min(1320px, calc(100% - 48px));
  min-height: 100vh;
  flex-direction: column;
  margin: 0 auto;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  box-shadow: none;
}

.site-frame:not(.admin-frame) .topbar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(210px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(14px, 2vw, 30px);
  min-height: 82px;
  margin-top: 16px;
  padding: 12px clamp(20px, 3.8vw, 48px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper-light);
  box-shadow: 0 4px 14px rgba(56, 46, 31, .04), inset 0 1px 0 rgba(255, 255, 255, .8);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid rgba(97, 67, 52, .18);
  border-radius: 14px;
  background-color: var(--brown-soft);
  box-shadow: 0 3px 10px rgba(56, 46, 31, .07);
}

.brand-text { min-width: 0; }
.brand-text strong {
  display: block;
  color: var(--ink);
  font: 600 .95rem/1.4 var(--sans);
  letter-spacing: 0;
  white-space: nowrap;
}
.brand-text small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font: 500 .72rem/1.3 var(--sans);
  letter-spacing: 0;
}

/* The public navigation lives in the header on every page. */
.site-frame:not(.admin-frame) .topbar > .main-nav {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, .7vw, 10px);
  margin: 0;
  padding: 0;
}

.site-frame:not(.admin-frame) .topbar > .main-nav a {
  display: inline-flex;
  min-width: 72px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 11px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font: 500 .94rem/1.4 var(--sans);
  white-space: nowrap;
  transition: color .16s ease, background-color .16s ease;
}

.site-frame:not(.admin-frame) .topbar > .main-nav a:hover,
.site-frame:not(.admin-frame) .topbar > .main-nav a.active {
  color: var(--brown-dark);
  background: var(--brown-wash);
  box-shadow: none;
}


.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-login {
  display: inline-flex;
  min-width: 88px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid rgba(128, 84, 67, .3);
  border-radius: 999px;
  color: var(--brown-dark);
  background: var(--paper-light);
  font: 600 .82rem/1.3 var(--sans);
  white-space: nowrap;
  transition: color .16s ease, border-color .16s ease, background-color .16s ease;
}

.topbar-login:hover, .topbar-login.active {
  color: var(--paper-light);
  border-color: var(--brown-dark);
  background: var(--brown-dark);
  transform: none;
}

/* The main landmark is the only child of app-layout in the public shell. */
.site-frame:not(.admin-frame) .app-layout {
  display: block;
  min-height: 0;
  flex: 1 0 auto;
}

.site-frame:not(.admin-frame) #app {
  min-width: 0;
  scroll-margin-top: 20px;
}

.site-frame:not(.admin-frame) .home-view,
.site-frame:not(.admin-frame) .inner-view {
  padding-right: var(--content-pad);
  padding-left: var(--content-pad);
}

.site-frame:not(.admin-frame) .page-intro { padding-top: clamp(32px, 5vw, 58px); }
.page-intro h1 {
  font-family: var(--sans);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: 0;
}
.hero-copy h1 { line-height: 1.12; letter-spacing: -.035em; }
.page-intro > p:last-child, .hero-copy > p { line-height: 1.82; }
.eyebrow, .module-label, .project-top, .project-bottom, .filter-caption,
.filter-count, .notes-result, .card-label {
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .015em;
}

.view { animation-duration: .42s; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font: 600 .9rem/1.35 var(--sans);
}

.button-primary { box-shadow: 0 4px 10px rgba(97, 67, 52, .1); }
.button-primary:hover { box-shadow: 0 6px 14px rgba(97, 67, 52, .13); transform: none; }
.module-link, .hero-actions .text-link, .qsl-actions .text-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}
.filter-chip { min-height: 42px; padding: 8px 13px; font: 600 .84rem/1.3 var(--sans); }
.load-more { min-height: 44px; font-size: .86rem; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brown);
  outline-offset: 3px;
}

#app:focus-visible { outline: none; }

.search-box { min-height: 48px; padding: 7px 13px; }
.search-box input,
.login-card input,
.qsl-form-grid input,
.qsl-form-grid textarea {
  font-size: 1rem;
  line-height: 1.5;
}
.search-box:focus-within { border-color: var(--brown); box-shadow: 0 0 0 3px rgba(138, 78, 55, .12); }
.login-card label > span, .qsl-form-grid label > span { font-size: .82rem; }
.login-card input, .qsl-form-grid input { min-height: 46px; }
.qsl-form-grid textarea { min-height: 112px; }
.github-login-button { min-height: 58px; }
.qsl-confirm { align-items: center; font-size: .84rem; }
.qsl-confirm input { width: 20px; height: 20px; flex: 0 0 20px; }

.modal-backdrop {
  z-index: 40;
  padding: clamp(12px, 3vw, 28px);
  overscroll-behavior: contain;
}

.project-modal, .qsl-form-modal {
  max-height: min(90vh, 850px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper-light);
  padding: clamp(22px, 3.6vw, 34px);
  overscroll-behavior: contain;
}

.modal-close {
  top: 8px;
  right: 8px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  font-size: 1.5rem;
}

/* The footer is a separate paper label with matching stationery details. */
.site-frame:not(.admin-frame) .site-footer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px 32px;
  margin: 18px 0 26px;
  padding: 28px var(--content-pad) 22px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(105, 59, 44, .012) 0 1px, transparent 1px 4px),
    var(--paper-light);
  box-shadow: 0 2px 0 #e9e2d7, 0 4px 0 -1px #d0c6b6, 0 12px 24px rgba(56, 46, 31, .055), inset 0 1px 0 rgba(255, 255, 255, .8);
  font: .88rem/1.6 var(--sans);
  letter-spacing: 0;
}
.site-frame:not(.admin-frame) .site-footer::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: -10px;
  left: calc(50% - 38px);
  width: 76px;
  height: 21px;
  pointer-events: none;
  transform: rotate(2deg);
  clip-path: polygon(1% 0, 99% 2%, 97% 20%, 100% 40%, 98% 60%, 100% 80%, 99% 100%, 1% 98%, 3% 78%, 0 58%, 2% 39%, 0 19%);
  background: linear-gradient(100deg, rgba(206, 175, 128, .36), rgba(225, 202, 163, .65), rgba(206, 175, 128, .4));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(105, 59, 44, .09);
}
.footer-intro strong { display: block; color: var(--ink); font: 600 1rem/1.4 var(--sans); }
.footer-intro p { margin: 6px 0 0; color: var(--muted); font-size: .88rem; }
.footer-channels { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px 10px; }
.footer-channels a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid #dfd3c4;
  border-radius: 7px;
  color: var(--muted);
  background: #f2ece2;
  box-shadow: 0 2px 0 rgba(128, 84, 67, .1), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.footer-channels a:hover {
  color: var(--brown);
  background: var(--brown-wash);
  box-shadow: 0 3px 0 rgba(128, 84, 67, .12), 0 5px 10px rgba(128, 84, 67, .06);
}
.footer-channels b { font: 500 .9rem/1.5 var(--sans); }
.footer-channels i { color: var(--brown); font-style: normal; }
.footer-bottom { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 18px; padding-top: 16px; border-top: 1px dashed var(--line-strong); color: var(--muted); font-size: .8rem; }
.footer-bottom a { color: var(--brown-dark); min-height: 44px; display: inline-flex; align-items: center; }
.footer-bottom a:hover { text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .footer-channels a:hover { transform: translateY(-2px); }
}

/* A soft, warm shadow follows the pointer inside paper surfaces. */
.interactive-surface::before, .pointer-glow::before, .footer-pointer-glow::after {
  border-radius: inherit;
  background: radial-gradient(260px circle at var(--pointer-x, 50%) var(--pointer-y, 50%), rgba(138, 78, 55, .12), transparent 68%);
  transition: opacity .24s ease;
}
.interactive-surface:hover::before, .pointer-glow:hover::before, .footer-pointer-glow:hover::after { opacity: 0; }
.footer-pointer-glow { isolation: isolate; }
.footer-pointer-glow::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.footer-pointer-glow > * { position: relative; z-index: 1; }
@media (hover: hover) and (pointer: fine) {
  .interactive-surface:hover::before, .pointer-glow:hover::before, .footer-pointer-glow:hover::after { opacity: 1; }
}
.project-card:hover, .dashboard-module:hover, .friend-card:hover,
.note-item:hover, .about-index > a:hover, .filter-chip:hover { transform: none; }

@media (max-width: 880px) {
  .site-frame:not(.admin-frame) .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 16px;
    padding-top: 10px;
    padding-bottom: 8px;
  }
  .site-frame:not(.admin-frame) .brand { grid-column: 1; grid-row: 1; }
  .site-frame:not(.admin-frame) .topbar-actions { grid-column: 2; grid-row: 1; }
  .site-frame:not(.admin-frame) .topbar > .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    padding-top: 3px;
  }
  .site-frame:not(.admin-frame) .topbar > .main-nav a {
    min-width: 0;
    min-height: 46px;
    gap: 0;
    padding: 8px 5px;
    border-radius: 11px;
    font-size: .88rem;
  }
}

@media (max-width: 650px) {
  :root { --content-pad: 20px; --body-size: 16px; }

  .site-frame:not(.admin-frame) {
    width: 100%;
    min-height: 100vh;
    margin: 0;
  }

  .site-frame:not(.admin-frame) .topbar {
    min-height: 0;
    gap: 7px 10px;
    margin: 10px 12px 0;
    padding: 12px 12px 8px;
    border-radius: 16px;
  }

  .brand { gap: 9px; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; border-radius: 13px; }
  .brand-text strong { font-size: .9rem; }
  .brand-text small { margin-top: 2px; font-size: .68rem; }
  .topbar-actions { gap: 5px; }
  .topbar-login { min-width: 82px; min-height: 44px; padding: 8px 10px; font-size: .8rem; }

  .site-frame:not(.admin-frame) .topbar > .main-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    padding-top: 3px;
  }

  .site-frame:not(.admin-frame) .topbar > .main-nav a {
    min-height: 46px;
    padding: 7px 2px;
    border-radius: 10px;
    font-size: .83rem;
    line-height: 1.25;
    text-align: center;
  }

  .site-frame:not(.admin-frame) .topbar > .main-nav a:hover,
  .site-frame:not(.admin-frame) .topbar > .main-nav a.active { background: var(--brown-wash); }
  .site-frame:not(.admin-frame) .page-intro { padding-top: 30px; }
  .home-hero { gap: 22px; }
  .page-intro > p:last-child, .hero-copy > p { font-size: .96rem; }
  .hero-actions { flex-wrap: wrap; gap: 10px 14px; }
  .button { min-height: 46px; }

  .site-frame:not(.admin-frame) .site-footer {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    margin: 18px 12px 22px;
    padding: 26px 18px 20px;
  }
  .footer-channels { justify-content: flex-start; gap: 9px; }
  .footer-channels a { padding: 8px 10px; }
  .footer-bottom { grid-column: 1; gap: 8px 14px; }

  .project-modal, .qsl-form-modal { max-height: 92vh; padding: 22px 18px; border-radius: 17px; }
  .project-modal h2, .qsl-form-modal h2 { padding-right: 32px; font-size: 1.65rem; }
  .modal-close { top: 5px; right: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .view { animation: none; }
  .footer-channels a { transition: none; }
  .footer-channels a:hover { transform: none; }
  .interactive-surface::before, .pointer-glow::before, .footer-pointer-glow::after { transition: none; }
  .button-primary:hover, .topbar-login:hover, .topbar-login.active,
  .project-card:hover, .dashboard-module:hover, .friend-card:hover,
  .note-item:hover, .about-index > a:hover, .filter-chip:hover { transform: none; }
}
