/*
  Starter stylesheet shared by the public pages, member area and blog.
  Rebrand a new site by editing the tokens in :root first; most components read from them.
*/

:root {
  --ink: #172c28;
  --muted: #5f6d66;
  --paper: #f7f8f3;
  --surface: #fff;
  --accent: #365f4c;
  --accent-soft: #eff3e9;
  --highlight: #ddef91;
  --line: #dfe4da;
  --field: #bac5b7;
  --focus: #7f9f36;
  --ok: #2f6b45;
  --ok-soft: #e3f1e6;
  --warn: #8a5a12;
  --warn-soft: #fff1df;
  --danger: #a03a2c;
  --danger-soft: #fbe7e3;
  --radius: 18px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(23 44 40 / 6%), 0 8px 24px rgb(23 44 40 / 6%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 var(--font);
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-underline-offset: 4px; }
img, svg { max-width: 100%; height: auto; }
h1, h2, h3, h4 { line-height: 1.12; letter-spacing: -.035em; margin: 0 0 .5em; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 5vw, 4.4rem); font-weight: 650; }
h2 { font-size: clamp(1.7rem, 3vw, 2.2rem); font-weight: 650; }
h3 { font-size: 1.35rem; font-weight: 650; }
p { color: var(--muted); margin: 0 0 1em; text-wrap: pretty; }
main { min-height: 45vh; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; }

.wrap { max-width: 1180px; padding-inline: 30px; margin-inline: auto; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 10px; top: 10px; background: var(--surface); padding: 10px; z-index: 99; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.preview-bar {
  text-align: center; background: var(--ink); color: var(--highlight);
  font-size: 11px; font-weight: 700; letter-spacing: .12em; padding: 10px;
}
.preview-bar span { margin-left: 18px; color: #d3dfd5; font-weight: 400; letter-spacing: .02em; }

/* ---------- Public header & footer ---------- */
.site-header { display: flex; justify-content: space-between; align-items: center; min-height: 100px; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.brand img { width: 34px; height: 34px; }
.site-header nav { display: flex; align-items: center; gap: 26px; font-size: 14px; }
.site-header nav a { text-decoration: none; }
.site-header nav a:hover { text-decoration: underline; }
.nav-login { border: 1px solid var(--line); padding: 10px 18px; border-radius: 30px; }

.site-footer {
  display: flex; justify-content: space-between; gap: 30px;
  padding-block: 45px; margin-top: 65px; border-top: 1px solid var(--line);
}
.site-footer p, .site-footer small { font-size: 12px; }
.site-footer nav { display: flex; gap: 22px; font-size: 13px; }

/* ---------- Buttons & links ---------- */
.button, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; background: var(--ink); color: #fff; border-radius: var(--radius-sm);
  padding: 13px 22px; font: 650 14px/1.2 var(--font); text-decoration: none; cursor: pointer;
  transition: background-color .15s ease;
}
.button:hover, button:hover { background: var(--accent); color: #fff; }
.button.secondary, button.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.button.secondary:hover, button.secondary:hover { background: var(--accent-soft); color: var(--ink); }
.button.small, button.small { padding: 8px 14px; font-size: 13px; }
button[disabled], .button[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.text-link { font-size: 14px; font-weight: 650; }

/* ---------- Marketing sections ---------- */
.eyebrow { display: inline-block; font-size: 11px; font-weight: 750; letter-spacing: .16em; color: var(--accent); text-transform: uppercase; }
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; padding: 65px 0 85px; }
.hero h1 { margin: 20px 0 26px; }
.hero em { font-style: normal; color: var(--accent); }
.hero figure { margin: 0; }
.hero img { width: 100%; }
.hero figcaption { margin-top: 16px; font-size: 10px; letter-spacing: .18em; color: var(--muted); text-align: center; }
.lead { font-size: 18px; line-height: 1.7; max-width: 470px; }
.actions { display: flex; gap: 24px; align-items: center; margin: 32px 0 20px; }
.note { font-size: 12px; }

.section { padding: 65px 0; border-top: 1px solid var(--line); }
.section-heading { max-width: 570px; margin-bottom: 32px; }
.section-heading h2 { margin-top: 15px; }
.grid { display: grid; gap: 22px; }
.three { grid-template-columns: repeat(3, 1fr); }
.two { grid-template-columns: repeat(2, 1fr); }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; background: var(--surface); }
.card h3 { margin: 28px 0 12px; }
.card p:last-child { margin-bottom: 0; }
.step { font-size: 12px; font-weight: 700; display: inline-block; color: var(--accent); padding: 7px 12px; background: var(--accent-soft); border-radius: var(--radius-sm); }

.cta {
  margin: 30px 0 65px; padding: 42px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: space-between; gap: 30px; background: var(--highlight);
}
.cta h2 { margin-top: 12px; }
.cta p { margin: 0; }

.faq { max-width: 800px; margin: auto; }
.faq h2 { margin-bottom: 28px; }
details { border-bottom: 1px solid var(--line); padding: 20px 0; }
summary { cursor: pointer; font-weight: 600; }
details p { margin-top: 16px; }

.page-intro { padding: 65px 0; max-width: 850px; }
.page-intro h1 { font-size: clamp(2.5rem, 5vw, 3.8rem); margin: 20px 0; }
.page-intro p { font-size: 18px; }

.price { font-size: 48px; color: var(--ink); }
.price small { font-size: 15px; font-weight: 400; color: var(--muted); }
.plan li { margin: 12px 0; }
.plan button { margin-top: 20px; background: #e6e9e1; color: #687266; cursor: not-allowed; }

.blog-card { display: grid; grid-template-columns: 1fr 1fr; gap: 35px; align-items: center; }
.blog-card img { border-radius: 12px; }

/* ---------- Forms ---------- */
label { font-size: 14px; font-weight: 600; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--field); border-radius: 7px;
  background: var(--surface); color: var(--ink); font: 15px/1.4 var(--font);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field .hint { font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; }

.alert { background: var(--warn-soft); border: 1px solid #e3c391; padding: 14px; border-radius: var(--radius-sm); color: var(--ink); }
.alert.ok { background: var(--ok-soft); border-color: #a9cfb3; }
.alert.danger { background: var(--danger-soft); border-color: #e4b2a8; }

/* ---------- Centered account screens (login, reset, messages) ---------- */
.auth { max-width: 520px; margin: 55px auto; padding: 38px; }
.auth > img { margin-bottom: 20px; }
.auth h1 { font-size: 32px; }
.auth form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.auth button { margin: 10px 0; }
.auth .links { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; margin-top: 8px; }

/* ---------- Member area ---------- */
.member { background: var(--paper); }
.app-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.app-header .wrap { display: flex; align-items: center; gap: 28px; min-height: 68px; }
.app-header .brand { font-size: 18px; }
.app-header .brand img { width: 28px; height: 28px; }
.app-nav { display: flex; gap: 4px; flex: 1; font-size: 14px; }
.app-nav a { padding: 8px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted); font-weight: 600; }
.app-nav a:hover { color: var(--ink); background: var(--accent-soft); }
.app-nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.app-user { display: flex; align-items: center; gap: 14px; font-size: 14px; white-space: nowrap; }
.app-user .name { color: var(--muted); }
.app-main { padding-block: 36px 60px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-head h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); margin: 6px 0 0; }
.page-head p { margin: 6px 0 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 22px; }
.panel h2 { font-size: 1.25rem; letter-spacing: -.02em; margin-bottom: 18px; }
.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.panel-grid > .panel + .panel { margin-top: 0; }

.welcome { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; background: var(--highlight); border-radius: var(--radius); padding: 28px 32px; margin-bottom: 22px; }
.welcome h2 { margin: 0 0 6px; }
.welcome p { margin: 0; color: var(--ink); opacity: .8; }

.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 0 0 8px; }
.meta dt { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.meta dd { margin: 2px 0 0; font-weight: 600; }

.table-scroll { overflow-x: auto; margin-inline: -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table select { width: auto; padding: 6px 10px; font-size: 14px; }
.table code, .badge { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--ink); border: 0; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
button.badge { cursor: pointer; }
button.badge:hover { filter: brightness(.96); }

.empty { text-align: center; padding: 48px 20px; }
.empty img { width: 96px; margin-bottom: 12px; }

/* Toast notifications (see /template/member.js) */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 100; max-width: min(380px, calc(100vw - 40px)); }
.toast { background: var(--ink); color: #fff; padding: 14px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: toast-in .2s ease-out; }
.toast strong { display: block; margin-bottom: 2px; }
.toast.ok { border-left: 4px solid var(--highlight); }
.toast.danger { border-left: 4px solid #f08a76; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Error pages ---------- */
.error-page { text-align: center; padding: 80px 0; max-width: 640px; margin: auto; }
.error-page .code { font-size: clamp(4rem, 12vw, 7rem); font-weight: 750; letter-spacing: -.06em; color: var(--accent); line-height: 1; }
.error-page .actions { justify-content: center; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app-header .wrap { flex-wrap: wrap; gap: 10px 20px; padding-block: 12px; }
  .app-nav { order: 3; flex-basis: 100%; overflow-x: auto; margin-inline: -12px; }
  .app-user { margin-left: auto; }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .wrap { padding-inline: 20px; }
  .site-header { flex-wrap: wrap; padding-block: 20px; gap: 18px; }
  .site-header nav { gap: 18px; flex-wrap: wrap; }
  .hero { grid-template-columns: 1fr; padding: 40px 0; gap: 30px; }
  .hero figure { max-width: 500px; }
  .grid, .blog-card { grid-template-columns: 1fr; }
  .cta, .site-footer { flex-direction: column; align-items: flex-start; }
  .cta { padding: 28px; }
  .actions { flex-wrap: wrap; gap: 18px; }
  .site-footer nav { flex-wrap: wrap; }
  .auth, .panel { padding: 22px; }
  .welcome { grid-template-columns: 1fr; padding: 24px; }
  .preview-bar span { display: block; margin: 4px 0 0; }
  .section { padding: 40px 0; }
  .app-user .name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
