/* ============================================================
   Ethica.no — page & layout styles
   ------------------------------------------------------------
   Masthead, nav, rail, blog list/rows, single post, prose,
   search, products grid, footer. Colour/type/spacing come from
   /css/theme.css; reusable widgets (.btn .card .badge .chip
   .field .panel .section .status) from /css/components.css.
   Never hardcode a hex here — reference a token. See DESIGN.md.
   ============================================================ */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-app);
  background-attachment: fixed;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, .list-title, .post-title, .prose h1, .prose h2, .prose h3,
.prow-title, .pn strong, .note-text, .masthead .brand-link h1 {
  font-family: var(--font-display); letter-spacing: -.01em;
}

.wrap { width: min(var(--layout-page-max), calc(100% - 44px)); margin: 0 auto; }
.muted { color: var(--color-text-soft); }
.serif-display { font-family: var(--font-display); }
.eyebrow {
  font-family: var(--font-mono); font-weight: 700; font-size: .72rem;
  letter-spacing: .18em; text-transform: uppercase; color: var(--color-text-muted);
}

/* Top bar + footer chrome (.ev-top / .ev-nav / .ev-foot) live in components.css
   so the public site AND the Python admin share one header. */

/* ---------- Theme menu ---------- */
.theme { position: relative; }
.theme-btn {
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  width: 32px; height: 32px; border-radius: var(--radius-pill); cursor: pointer;
  font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.theme-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.theme-menu {
  position: absolute; right: 0; top: 40px; z-index: 60; min-width: 130px; padding: 6px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel); backdrop-filter: blur(13px); -webkit-backdrop-filter: blur(13px);
}
.theme-menu[hidden] { display: none; }
.theme-menu button { display: flex; width: 100%; gap: 8px; align-items: center; border: 0; background: transparent; color: var(--color-text); cursor: pointer; font-family: inherit; font-size: .9rem; padding: 8px 10px; border-radius: 7px; text-align: left; }
.theme-menu button:hover { background: var(--color-surface-elevated); }

/* ---------- Login / admin menu in nav ---------- */
.loginslot { display: inline-flex; align-items: center; }
.adminwrap { position: relative; }
.adminbtn { background: none; border: 0; cursor: pointer; font: inherit; color: var(--color-text-muted); font-weight: 600; font-size: .82rem; letter-spacing: .12em; text-transform: uppercase; }
.adminbtn:hover { color: var(--color-primary); }
.adminmenu {
  position: absolute; right: 0; top: 30px; z-index: 60; min-width: 170px; padding: 6px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel); backdrop-filter: blur(13px); -webkit-backdrop-filter: blur(13px);
}
.adminmenu[hidden] { display: none; }
.adminmenu a, .adminmenu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 7px; color: var(--color-text); font: inherit; font-size: .88rem; background: none; border: 0; cursor: pointer; text-transform: none; letter-spacing: 0; }
.adminmenu a:hover, .adminmenu button:hover { background: var(--color-surface-elevated); text-decoration: none; }
.adminmenu form { margin: 4px 0 0; border-top: 1px solid var(--color-border); padding-top: 4px; }
.adminmenu form button { color: var(--color-danger); font-weight: 600; }

/* ---------- Sidebar / rail ---------- */
.rail { display: flex; flex-direction: column; gap: 22px; }
.widget {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-soft); overflow: hidden;
  backdrop-filter: blur(13px); -webkit-backdrop-filter: blur(13px);
}
.widget-tab { display: inline-block; background: var(--color-primary); color: var(--color-on-primary); font-size: .66rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; padding: 4px 12px; border-radius: 0 0 6px 0; }
.widget-body { padding: 16px; }
.widget h3.wtitle { font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .78rem; margin: 0 0 12px; color: var(--color-text); }

.about-top { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.about-top img { width: 96px; height: 96px; border-radius: var(--radius-pill); object-fit: cover; border: 3px solid var(--color-surface-elevated); }
.about-top .name { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; }
.about-bio { color: var(--color-text-muted); font-size: .9rem; text-align: center; margin: 8px 0 4px; }
.about-links { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--color-border); }
.about-links li { border-bottom: 1px solid var(--color-border); }
.about-links a { display: flex; align-items: center; gap: 10px; padding: 11px 2px; color: var(--color-text); font-size: .9rem; }
.about-links a:hover { color: var(--color-primary); text-decoration: none; }
.about-links .chev { margin-left: auto; color: var(--color-text-soft); }
.about-links li:last-child { border-bottom: 0; }

.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; font-size: .92rem; color: var(--color-text); }
.todo .box { width: 15px; height: 15px; border: 1.5px solid var(--color-text-soft); border-radius: 3px; margin-top: 3px; flex: 0 0 auto; display: grid; place-items: center; font-size: 10px; color: var(--color-primary); }
.todo li.done { color: var(--color-text-soft); }
.todo li.done .box { border-color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 16%, transparent); }
.todo li.done .task { text-decoration: line-through; }

/* ---------- Explore topics (chip container; .chip itself is in components.css) ---------- */
.topics { margin-top: 40px; }
.topics-head { margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 12px; }
.chips--lg .chip { font-size: .9rem; padding: 9px 13px; }

/* ---------- Footer ---------- */
/* .ev-foot lives in components.css (shared with admin) */

/* ---------- Floating "back to top" ---------- */
.totop {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 38px; height: 38px; border-radius: var(--radius-pill); cursor: pointer;
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  box-shadow: var(--shadow-soft); font-size: 16px; line-height: 1;
  transition: opacity .2s ease, transform .2s ease;
  backdrop-filter: blur(13px); -webkit-backdrop-filter: blur(13px);
}
.totop:hover { border-color: var(--color-primary); color: var(--color-primary); }
.totop.hide { opacity: 0; transform: translateY(8px); pointer-events: none; }

.page-wrap { padding: 36px 0 64px; }

/* ---------- List / term pages (landing-style hero + card grid) ---------- */
.list-hero { padding: 60px 0 30px; }
.list-hero .list-title { margin: .22em 0 .12em; }
.list-hero .lede, .list-hero .list-intro, .list-head .lead { max-width: 60ch; font-size: 1.12rem; color: var(--color-text-muted); margin-top: 4px; }
.list-head { border-bottom: 1px solid var(--color-border); padding-bottom: 18px; margin-bottom: 28px; }
.list-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.02; margin: 8px 0 6px; letter-spacing: -.015em; }
.list-count { color: var(--color-text-soft); font-size: .9rem; margin: 0; }
.list-intro { margin-top: 12px; }

/* post cards */
.postgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--layout-gap); }
.post-card { display: flex; flex-direction: column; }
.post-card .ptitle { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; line-height: 1.18; margin: 10px 0 8px; }
.post-card .ptitle a { color: var(--color-text); }
.post-card:hover .ptitle a { color: var(--color-primary); }
.post-card .pdek { color: var(--color-text-muted); font-size: .94rem; margin: 0 0 16px; }
.post-card .pmeta { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-top: auto; color: var(--color-text-soft); font-size: .8rem; border-top: 1px solid var(--color-border); padding-top: 12px; }
.post-card .ptags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tagmini { color: var(--color-primary); font-size: .8rem; }
.tagmini:hover { color: var(--color-primary-hover); text-decoration: none; }

.kicker { font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--color-primary); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 32px; border-top: 1px solid var(--color-border); padding-top: 18px; }
.pager-btn { font-weight: 600; color: var(--color-text); }
.pager-btn:hover { color: var(--color-primary); text-decoration: none; }
.pager-info { color: var(--color-text-soft); font-size: .85rem; }

/* ---------- Single post ---------- */
.post { max-width: var(--layout-content-max); margin: 0 auto; }
.back { display: inline-block; color: var(--color-text-muted); font-size: .85rem; letter-spacing: .04em; margin-bottom: 18px; }
.post-head { border-bottom: 1px solid var(--color-border); padding-bottom: 20px; margin-bottom: 24px; }
.post-head .kicker { display: inline-block; margin-bottom: 10px; }
.post-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1.04; margin: 0 0 14px; letter-spacing: -.015em; }
.post-standfirst { font-size: 1.2rem; color: var(--color-text-muted); line-height: 1.4; margin: 0 0 16px; }
.post-meta { color: var(--color-text-soft); font-size: .88rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.post-meta .dot { opacity: .5; }
.post-hero { margin: 0 0 28px; }
.post-hero img { width: 100%; max-height: 460px; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--color-border); }

.toc { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 12px 18px; margin: 0 0 28px; }
.toc summary { cursor: pointer; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: .76rem; color: var(--color-text-muted); }
.toc ul { margin: 10px 0 0; padding-left: 18px; }
.toc a { color: var(--color-primary); }

/* ---------- Prose (article body) ---------- */
.prose { font-size: 1.08rem; line-height: 1.72; color: var(--color-text); overflow-wrap: break-word; }
.prose > * + * { margin-top: 1.1em; }
.prose h2, .prose h3, .prose h4 { font-family: var(--font-display); line-height: 1.15; margin-top: 1.8em; }
.prose h2 { font-size: 1.8rem; font-weight: 700; padding-bottom: 6px; border-bottom: 1px solid var(--color-border); }
.prose h3 { font-size: 1.4rem; font-weight: 700; }
.prose h4 { font-size: 1.15rem; font-weight: 700; }
.prose a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.prose a:hover { color: var(--color-primary-hover); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .4em; }
.prose blockquote {
  margin: 1.4em 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--color-primary);
  color: var(--color-text-muted); font-style: italic;
  backdrop-filter: blur(13px); -webkit-backdrop-filter: blur(13px);
}
.prose img { max-width: 100%; height: auto; border-radius: var(--radius-md); border: 1px solid var(--color-border); }
.prose figure { margin: 1.6em 0; }
.prose figure figcaption { color: var(--color-text-soft); font-size: .85rem; text-align: center; margin-top: 8px; }
.prose hr { border: 0; border-top: 1px solid var(--color-border); margin: 2em 0; }
.prose code { font-family: var(--font-mono); font-size: .88em; background: var(--color-surface-elevated); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: .1em .35em; }
.prose pre {
  background: var(--color-surface-elevated); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 16px 18px; overflow-x: auto; font-size: .9rem; line-height: 1.5; max-width: 100%;
  backdrop-filter: blur(13px); -webkit-backdrop-filter: blur(13px);
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose table { width: 100%; border-collapse: collapse; font-size: .94rem; max-width: 100%; }
.prose th, .prose td { border: 1px solid var(--color-border); padding: 8px 12px; text-align: left; }
.prose th { background: var(--color-surface-elevated); }
.prose .table-wrap { overflow-x: auto; }

/* ---------- Post footer ---------- */
.post-foot { max-width: var(--layout-content-max); margin: 36px auto 0; border-top: 1px solid var(--color-border); padding-top: 20px; }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.tagchip { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-pill); padding: 4px 12px; font-size: .82rem; color: var(--color-text); }
.tagchip:hover { border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pn { display: flex; flex-direction: column; gap: 4px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px 16px; }
.pn span { color: var(--color-text-soft); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
.pn strong { font-family: var(--font-display); font-weight: 700; color: var(--color-text); }
.pn:hover { border-color: var(--color-primary); text-decoration: none; }
.pn.next { text-align: right; }
@media (max-width: 620px){ .prevnext { grid-template-columns: 1fr; } .pn.next { text-align: left; } }

/* ---------- Search page ---------- */
.search-page { max-width: var(--layout-content-max); margin: 0 auto; }
.search-box { display: flex; align-items: center; gap: 10px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px 18px; color: var(--color-text-muted); box-shadow: var(--shadow-soft); }
.search-box input { border: 0; background: transparent; color: var(--color-text); font-family: inherit; font-size: 1.1rem; width: 100%; outline: none; }
#search-status { margin: 14px 2px; }

/* ---------- Products grid (cards themselves are .card.card--project in components.css) ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--layout-gap); }

/* ---------- 404 ---------- */
.error404 { text-align: center; padding: 70px 0 90px; }
.error404 .lead { max-width: 44ch; margin: 0 auto 26px; color: var(--color-text-muted); }
.e404-links { display: flex; gap: 12px; justify-content: center; }

/* ---------- Shortcodes: audio + gallery ---------- */
.audio-player { display: flex; gap: 16px; align-items: center; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px; margin: 1.4em 0; }
.audio-cover { width: 72px; height: 72px; border-radius: var(--radius-sm); object-fit: cover; flex: 0 0 auto; border: 1px solid var(--color-border); }
.audio-content { flex: 1 1 auto; min-width: 0; }
.audio-title { font-weight: 700; margin: 0 0 8px; }
.audio-player audio { width: 100%; }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 1.6em 0; }
.photo-gallery figure { margin: 0; }
.photo-gallery img { width: 100%; height: 180px; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--color-border); cursor: zoom-in; }

.mon-lamp { display: inline-block; width: 10px; height: 10px; border-radius: var(--radius-pill); vertical-align: middle; }
.note-text { font-family: var(--font-display); font-size: 1.05rem; line-height: 1.3; margin: 0 0 8px; }
.note-cite { font-style: normal; color: var(--color-text-muted); font-size: .85rem; }

/* ---------- Reusable rail layout on inner pages ----------
   minmax(0,1fr) lets the main column shrink instead of being inflated by wide
   content (code blocks, tables, long strings) which would push the fixed rail. */
.wrap.has-rail { display: grid; grid-template-columns: minmax(0, 1fr) var(--layout-sidebar); gap: 36px; align-items: start; }
.rail-main { min-width: 0; }
.has-rail .rail { width: var(--layout-sidebar); position: sticky; top: 24px; }
.has-rail .post { max-width: none; margin: 0; }
.has-rail .post-foot { max-width: none; }
@media (max-width: 768px) {
  .wrap.has-rail { grid-template-columns: 1fr; }
  .has-rail .rail { width: auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
}
@media (max-width: 480px) { .has-rail .rail { grid-template-columns: 1fr; } }

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  .rail { grid-template-columns: 1fr; }
  .ev-foot .wrap { flex-direction: column; text-align: center; }
}
