/* ============================================================
   SCHOOL MAGAZINE — DESIGN SYSTEM
   ------------------------------------------------------------
   Palette
     --header-bg    #000000  Pure black header rows
     --header-fg    #FFFFFF  White text on header
     --brand        #009EE0  Scio light blue accent (divider, hover)
     --content-bg   #EBF0F3  Soft slate gray content background
     --surface      #FFFFFF  Card / panel surface (floats on the gray)
     --content-fg   #1A1A1A  Dark charcoal body text
     --content-rule #DDDDDD  Subtle divider in content
     --accent       #000000  Black buttons
   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32 / 48
   Typography: system stack, body 16px, h1 ~2rem, h2 1.4rem
   ============================================================ */

:root {
  --brand:        #16a9e0;   /* Scio light blue — matches the logo cyan */

  /* header rows (kept under the old --sidebar-* names for compatibility) */
  --sidebar-bg:   #000000;
  --sidebar-fg:   #ffffff;
  --sidebar-rule: #333333;

  --content-bg:   #ebf0f3;   /* soft slate gray (alt: #f4f4f6) */
  --surface:      #ffffff;
  --content-fg:   #1a1a1a;
  --muted:        #5b6770;
  --content-rule: #e2e6ea;
  --accent:       #000000;

  --card-shadow:  0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.05);
  --card-shadow-hover: 0 8px 24px rgba(16, 24, 40, 0.10), 0 2px 6px rgba(16, 24, 40, 0.06);

  --max-content: 1200px;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, "Noto Sans", sans-serif;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--content-fg);
  background: var(--content-bg);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;            /* guard against accidental horizontal scroll */
}

img { display: block; max-width: 100%; }
a   { color: inherit; }
button { font: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 100;
  padding: 8px 16px;
  background: var(--surface);
  color: var(--content-fg);
  border: 1px solid var(--accent);
}
.skip-link:focus { top: 12px; }

/* ============================================================
   SITE HEADER — full-width, two black rows + Scio-blue divider.
   Element keeps id="sidebar" plus #burger / #sidebar-backdrop so the
   existing JavaScript (nav switching, drawer hooks) works unchanged.
   ============================================================ */
.site-header {
  width: 100%;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  position: relative;
  z-index: 30;
}

/* ROW 1 — logo on the LEFT, vertically centered, with the inline-SVG
   "split" divider behind it. Height is fixed so the SVG geometry (drawn
   in 1:1 pixel units) frames the logo exactly. overflow:hidden clips the
   divider's long right-hand segment to the current header width. */
.header-top {
  position: relative;
  height: 220px;              /* whole header; line + bracket centered within */
  overflow: hidden;
}

/* The split divider.
   No viewBox  -> 1 user unit == 1 px, so the 45° angles NEVER skew and the
   stroke never scales when the header resizes; the right segment (drawn far
   off-canvas at x=4000) is simply clipped to the header width. */
.header-divider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.header-divider .hd-line {
  fill: none;
  stroke: var(--brand);              /* Scio light blue (matches logo) */
  stroke-width: 3;
  stroke-linejoin: miter;            /* keeps the 45° corners crisp */
  stroke-linecap: square;
  vector-effect: non-scaling-stroke; /* stroke stays 3px at any size */
}

/* Navigation — pinned bottom-right of the header, below the centered line */
.site-nav {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-content);
  padding: 0 20px;
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  z-index: 2;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-logo {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--brand);
  color: var(--brand);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1rem;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }  /* drop a logo PNG here */
.brand-text { min-width: 0; text-align: left; }
.brand-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

/* Logo image — left, vertically centered in the whole header, framed by the
   bracket. Fixed size so the fixed SVG geometry always clears it. */
.site-logo {
  position: absolute;
  left: 36px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  line-height: 0;
}
.site-logo img {
  display: block;
  height: 128px;       /* bigger logo */
  width: auto;
}
.nav-link {
  display: inline-block;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--sidebar-fg);
  text-decoration: none;
  font: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;
}
.nav-link:hover { color: var(--brand); }
.nav-link.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* Burger kept in the DOM for the JS drawer hooks; the header simply
   wraps its nav on small screens, so the burger stays hidden. */
.burger {
  display: none;
  margin-left: auto;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--sidebar-fg);
  border-radius: 2px;
  padding: 0;
}
.burger span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  background: var(--sidebar-fg);
}

/* Backdrop kept for JS compatibility (unused by the header layout) */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}
.sidebar-backdrop[hidden] { display: none; }

/* ============================================================
   CONTENT
   ============================================================ */
.content {
  width: 100%;
  max-width: var(--max-content);   /* centered 1200px wrapper */
  margin: 0 auto;
  min-height: calc(100vh - 170px); /* keep the footer near the bottom */
  display: flex;
  flex-direction: column;
  padding: 40px 20px 0;            /* 40px top, 20px sides */
}

.page-header { margin-bottom: 32px; }
.page-title {
  margin: 0 0 6px;
  font-size: clamp(1.8rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-lead {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.section-title {
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--content-rule);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Page switching — only one .page visible at a time */
.page { display: none; max-width: var(--max-content); width: 100%; }
.page.is-active { display: block; }
.page[hidden] { display: none !important; }

/* ============================================================
   CARD GRID (Home + Articles)
   Fixed rows / aspect ratios so layout never jumps as images load
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.card {
  display: grid;
  /* Image row is fixed-height via aspect-ratio; the rest is auto. */
  grid-template-rows: auto 1fr auto;
  background: var(--surface);
  border: 1px solid var(--content-rule);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  /* Only shadow/border change on hover — no transform, no layout shift. */
  transition: box-shadow 160ms ease, border-color 160ms ease;
}
.card:hover {
  border-color: #d2d7dc;
  box-shadow: var(--card-shadow-hover);
}

.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;          /* locks image height regardless of source */
  background: #eaeaea;            /* placeholder colour while image loads */
  overflow: hidden;
}
.card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;              /* never distort, never reflow */
}

.card-body {
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-media { display: block; }
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.82rem;
}
.card-meta time::before { content: ""; }
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 16px;
}
/* Badges (article tags + sidebar quick-tags) — soft branded pills */
.card-tag,
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  color: #0a7bb0;
  background: rgba(22, 169, 224, 0.12);
  border: 1px solid rgba(22, 169, 224, 0.22);
}

/* ============================================================
   PAGINATION — static, anchored, never reflows on image load
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  /* Top margin is a fixed value (not "auto") so the button doesn't jump
     when grid items finish loading. */
  margin: 40px 0 48px;
}

.btn {
  min-height: 42px;
  padding: 0 24px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 2px;
}
.btn:hover { background: var(--surface); color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--content-fg);
  border-color: var(--content-fg);
}
.btn-ghost:hover { background: var(--accent); color: #ffffff; }

/* ============================================================
   ARTICLES — Tag filter
   ============================================================ */
.tag-filter {
  margin: 0 0 32px;
  padding: 16px 20px;
  border: 1px solid var(--content-rule);
  border-radius: 4px;
  background: var(--surface);
}
.tag-filter legend {
  padding: 0 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 8px 0 12px;
}
.tag-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--content-rule);
  border-radius: 2px;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  background: #fafafa;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.tag-checkbox input {
  /* keep the native input for accessibility; visually hide it */
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  margin: 0; padding: 0;
}
.tag-checkbox:has(input:checked) {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.tag-checkbox:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.empty-state {
  margin: 24px 0;
  padding: 24px;
  border: 1px dashed var(--content-rule);
  border-radius: 4px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
}

/* ============================================================
   ABOUT — prose + team grid
   ============================================================ */
.prose {
  max-width: 70ch;
  background: var(--surface);
  border: 1px solid var(--content-rule);
  border-radius: 4px;
  padding: 24px 28px;
}
.prose p { margin: 0 0 14px; }
.prose p:last-child { margin-bottom: 0; }

.team-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.team-card {
  background: var(--surface);
  border: 1px solid var(--content-rule);
  border-radius: 4px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto;  /* image, then text — fixed structure */
}
.team-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;            /* identical dimensions for every member */
  background: #eaeaea;
  overflow: hidden;
}
.team-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;              /* uniform crop */
}
.team-body {
  padding: 14px 16px 16px;
  text-align: center;
}
.team-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.team-role {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ============================================================
   CONTACT
   ============================================================ */
.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 720px;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--content-rule);
  border-radius: 4px;
  text-decoration: none;
  color: var(--content-fg);
  transition: border-color 120ms ease, background-color 120ms ease;
}
.contact-item:hover { border-color: var(--accent); background: #fafafa; }
.contact-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--content-rule);
  border-radius: 50%;
  color: var(--content-fg);
  background: #fafafa;
}
.contact-text { display: flex; flex-direction: column; min-width: 0; }
.contact-label { font-size: 0.78rem; color: var(--muted); }
.contact-value { font-size: 0.98rem; font-weight: 600; }

/* ============================================================
   FOOTER
   ============================================================ */
.content-footer {
  margin-top: auto;               /* pushes footer to bottom of content column */
  padding: 48px 0 32px;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--content-rule);
}
.content-footer p { margin: 24px 0 0; }

/* ============================================================
   HOME — editorial rule, eyebrow, featured card, sidebar
   ============================================================ */
/* Thin rule above the page header */
.editorial-rule {
  border: 0;
  border-top: 1px solid #cccccc;
  margin: 0 0 24px;
}
/* Small uppercase sub-header above the grid */
.grid-eyebrow {
  margin: 0 0 16px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Two-column layout: feed (left) + sidebar (right) */
.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;   /* ~75% / 25% */
  gap: 32px;
  align-items: start;
}
.home-main { min-width: 0; }
.home-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 20px;
}

/* Featured card — full width, image left + content right */
.card--featured {
  grid-column: 1 / -1;
  grid-template-rows: auto;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}
.card--featured .card-media {
  aspect-ratio: auto;
  height: 100%;
  min-height: 300px;
}
.card--featured .card-body {
  padding: 24px 28px;
  gap: 10px;
  justify-content: center;
}
.card--featured .card-title { font-size: 1.6rem; line-height: 1.2; }
.card--featured .card-tags { padding: 0; margin-top: 6px; }
.card-eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
}
.card-excerpt {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

/* Sidebar widgets */
.widget {
  background: var(--surface);
  border: 1px solid var(--content-rule);
  border-radius: 8px;
  padding: 18px 18px 20px;
  box-shadow: var(--card-shadow);
}
.widget-title {
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--content-rule);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.widget p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
}
.widget-photo {
  width: 100%;
  aspect-ratio: 16 / 10;
  margin-bottom: 12px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, #dfe6ec, #eef2f5);
}
.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ============================================================
   FLOATING WHITE SURFACES on the gray background
   ============================================================ */
.team-card,
.contact-item,
.prose,
.tag-filter,
.empty-state {
  box-shadow: var(--card-shadow);
}
.team-card,
.contact-item,
.prose,
.tag-filter { border-radius: 8px; }
.contact-item { transition: box-shadow 160ms ease, border-color 160ms ease; }
.contact-item:hover { box-shadow: var(--card-shadow-hover); }

/* ============================================================
   RESPONSIVE — tablet
   ============================================================ */
@media (max-width: 960px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .team-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* Sidebar drops below the feed and its widgets sit side by side */
  .home-layout { grid-template-columns: 1fr; gap: 24px; }
  .home-sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .home-sidebar .widget { flex: 1 1 260px; }
}

/* ============================================================
   RESPONSIVE — mobile (double-row header stacks, nav wraps)
   ============================================================ */
@media (max-width: 720px) {
  /* Header stacks: logo on top, nav below a simple blue rule (no bracket). */
  .header-top { height: auto; overflow: visible; }
  .header-divider { display: none; }
  .site-logo { position: static; transform: none; padding: 14px 0 14px 16px; }
  .site-logo img { height: 58px; }
  .site-nav {
    position: static; transform: none;
    width: 100%; max-width: none; padding: 8px 8px;
    justify-content: flex-start; flex-wrap: wrap;
    border-top: 3px solid var(--brand);
  }
  .nav-link { padding: 12px 10px; font-size: 0.92rem; }

  .content {
    padding: 28px 16px 0;
    min-height: auto;
  }

  .card-grid { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-list { grid-template-columns: 1fr; }

  /* Featured card stacks (image on top) */
  .card--featured { grid-template-columns: 1fr; }
  .card--featured .card-media { aspect-ratio: 16 / 10; height: auto; min-height: 0; }
  .card--featured .card-body { padding: 18px 16px; }
  .card--featured .card-title { font-size: 1.3rem; }
  .home-sidebar { flex-direction: column; }

  .page-header { margin-bottom: 24px; }
}

/* ============================================================
   RESPONSIVE — small phones
   ============================================================ */
@media (max-width: 460px) {
  .team-grid { grid-template-columns: 1fr; }
  .card-body { padding: 14px 14px 6px; }
  .card-tags { padding: 0 14px 14px; }
  .nav-link { padding: 10px 8px; font-size: 0.88rem; }
}

/* ============================================================
   ADMIN DASHBOARD — two-column layout (sidebar + main)
   Used by /admin. Component styles (forms, tables, login, toast)
   live inline in admin/index.html.
   ============================================================ */
.admin-layout {
  display: block;        /* single column — admin nav now lives in the header */
  min-height: 50vh;
}

/* Left black sidebar */
.admin-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  padding: 28px 18px;
}
.admin-brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0 10px;
}
.admin-divider {
  border: 0;
  border-top: 1px solid var(--sidebar-rule);
  margin: 20px 0;
}
.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 20px;
  border-top: 1px solid var(--sidebar-rule);
}
/* Admin nav buttons — horizontal, in the header (same look as .nav-link) */
.admin-nav-link {
  display: inline-block;
  padding: 12px 12px;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--sidebar-fg);
  font: inherit;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;
}
.admin-nav-link:hover { color: var(--brand); }
.admin-nav-link.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* Main content — centered like the public site */
.admin-main {
  min-width: 0;
  max-width: var(--max-content);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 48px) 20px;
  background: var(--content-bg);
}
.admin-section-title {
  margin: 0 0 28px;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.admin-section .subhead {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
/* Two-column form + table inside a section */
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 40px;
  align-items: start;
}
@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; gap: 28px; }
}

/* Admin responsive — sidebar becomes a top bar */
@media (max-width: 800px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 6px;
    padding: 14px 16px;
  }
  .admin-brand { flex: 1 1 100%; padding: 0 2px 4px; font-size: 1.05rem; }
  .admin-divider { display: none; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .admin-sidebar-footer {
    margin-top: 0;
    flex-direction: row;
    border-top: 0;
    padding-top: 0;
    margin-left: auto;
    gap: 6px;
  }
  .admin-nav-link { width: auto; padding: 9px 12px; font-size: 0.9rem; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ============================================================
   VISUAL ARTICLE EDITOR (Canva + Google-Docs hybrid)
   Used by /admin. Overlay editor with a positioned element canvas,
   dual toolbar, inline rich-text tools and a color panel.
   ============================================================ */
.ed-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: rgba(10, 16, 20, 0.55);
}
.ed-overlay[hidden] { display: none !important; }

.ed-workspace {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--content-bg);
}

/* ---- Bar 1 — top control bar (blue border) ---- */
.ed-bar1 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 2px solid var(--brand);
  border-radius: 8px;
}
.ed-bar1 .ed-spacer { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.ed-btn {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--content-rule);
  border-radius: 4px;
  background: var(--surface);
  color: var(--content-fg);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.ed-btn:hover { border-color: var(--brand); color: var(--brand); }
.ed-btn--danger:hover { border-color: #b00020; color: #b00020; }

/* ---- Bar 2 — tools & formatting ---- */
.ed-bar2 {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin: 0 12px 12px;
}
.ed-bar2-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--content-rule);
  border-radius: 8px;
}
.ed-bar2-right {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--content-rule);
  border-radius: 8px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.ed-bar2-right.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.ed-add-btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.ed-add-btn:hover { background: var(--brand); border-color: var(--brand); }

/* ---- Rich-text tools ---- */
.ed-fontsize {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--content-rule);
  border-radius: 4px;
  overflow: hidden;
}
.ed-fontsize button {
  width: 30px; height: 34px;
  border: 0; background: var(--surface);
  color: var(--content-fg); font-size: 1.05rem; cursor: pointer;
}
.ed-fontsize button:hover { background: #eef3f6; }
.ed-fontsize .ed-fs-val {
  width: 48px; height: 34px;
  border: 0; border-left: 1px solid var(--content-rule); border-right: 1px solid var(--content-rule);
  text-align: center; font: inherit; font-size: 0.9rem;
  background: var(--surface); color: var(--content-fg);
  -moz-appearance: textfield;
}
.ed-fs-val::-webkit-outer-spin-button,
.ed-fs-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.ed-tool {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--content-fg);
  font-size: 1.05rem; line-height: 1;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.ed-tool:hover { background: #eef3f6; }
.ed-tool.is-active,
.ed-tool.btn-active {
  background: rgba(22, 169, 224, 0.16);
  border-color: var(--brand);
  color: var(--brand);
}
.ed-tool-svg { padding: 0; }
.ed-bar2-right { flex-wrap: wrap; row-gap: 6px; }

/* Lists (editor + public) — marker inherits text color; long lines wrap
   under the text, a new bullet/number appears only on Enter (native <li>). */
.ed-el-content ul, .ed-el-content ol,
.ac-el ul, .ac-el ol {
  margin: 0.35em 0;
  padding-left: 1.5em;
}
.ed-el-content li, .ac-el li { line-height: 1.55; }
.ed-el-content li::marker, .ac-el li::marker { color: inherit; }

/* Indent — applied as inline padding-left on the block paragraph.
   Wrapping continues under the indent automatically (block padding);
   Enter ends the paragraph -> next paragraph starts without it. */
.ed-el-content div, .ed-el-content p,
.ac-el div, .ac-el p { margin: 0; }
.ed-tool-b { font-weight: 800; }
.ed-tool-i { font-style: italic; font-weight: 600; }
.ed-tool-u { text-decoration: underline; font-weight: 600; }
.ed-tool-o { font-weight: 800; }

/* ---- Color panel ---- */
.ed-color-wrap { position: relative; }
.ed-color-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 10;
  width: 244px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--content-rule);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.18);
}
.ed-color-panel[hidden] { display: none !important; }
.ed-color-preview {
  height: 40px; border-radius: 6px; border: 1px solid var(--content-rule);
  margin-bottom: 12px;
}
.ed-color-native { width: 100%; height: 36px; padding: 0; border: 1px solid var(--content-rule); border-radius: 6px; background: none; cursor: pointer; margin-bottom: 12px; }
.ed-color-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ed-color-row label { width: 16px; font-size: 0.8rem; color: var(--muted); }
.ed-color-row input[type="range"] { flex: 1; }
.ed-color-row input[type="number"] {
  width: 56px; height: 30px; padding: 2px 6px;
  border: 1px solid var(--content-rule); border-radius: 4px; font: inherit; font-size: 0.82rem;
}
.ed-color-hexrow { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.ed-color-hexrow label { font-size: 0.8rem; color: var(--muted); }
.ed-color-hexrow input {
  flex: 1; height: 32px; padding: 2px 8px; text-transform: uppercase;
  border: 1px solid var(--content-rule); border-radius: 4px; font: inherit; font-size: 0.85rem;
}

/* ---- Body row: left meta sidebar + canvas ---- */
.ed-body {
  flex: 1 1 auto;
  display: flex;
  gap: 12px;
  min-height: 0;
  margin: 0 12px 12px;
}

/* Left metadata sidebar */
.ed-side {
  flex: 0 0 248px;
  overflow: auto;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--content-rule);
  border-radius: 8px;
}
.ed-side-title {
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--content-rule);
  font-size: 0.95rem; font-weight: 700;
}
.ed-side label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.74rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.ed-side input, .ed-side select {
  width: 100%; min-height: 38px; margin-top: 6px;
  padding: 6px 10px; border: 1px solid var(--content-rule); border-radius: 4px;
  font: inherit; font-size: 0.92rem; text-transform: none; letter-spacing: 0; color: var(--content-fg);
  background: var(--surface);
}
/* scheduling: purple border when a future date is chosen */
.ed-date-field {
  display: block; margin-top: 6px;
  border: 2px solid transparent; border-radius: 6px; padding: 2px;
  transition: border-color 150ms ease;
}
.ed-date-field input { margin-top: 0; border: 1px solid var(--content-rule); }
.ed-date-field.is-scheduled { border: 2px solid purple; }
.ed-sched-hint {
  display: block; margin-top: 6px;
  font-size: 0.72rem; text-transform: none; letter-spacing: 0; color: purple; font-weight: 600;
}
.ed-sched-hint[hidden] { display: none; }

/* Canvas — white "paper" that mimics the public reader view */
.ed-canvas-wrap {
  flex: 1 1 auto;
  overflow: auto;
  padding: 24px;
  background: var(--content-bg);
  border: 1px solid var(--content-rule);
  border-radius: 8px;
}
.ed-canvas {
  position: relative;
  width: 820px;
  max-width: 100%;
  min-height: 1100px;
  margin: 0 auto;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 18px rgba(16, 24, 40, 0.12);
}

/* Custom selection highlight on canvas text (no default blue/white) */
.ed-el-content::selection,
.ed-el-content *::selection {
  background: rgba(22, 169, 224, 0.18);
  color: inherit;
}
.ed-el-content::-moz-selection,
.ed-el-content *::-moz-selection {
  background: rgba(22, 169, 224, 0.18);
  color: inherit;
}

/* ---- Element boxes ---- */
.ed-el {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 2px;
  user-select: none;
}
.ed-el.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
  z-index: 50;
}
.ed-el-content {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 6px 8px;
  outline: none;
  overflow: hidden;
  cursor: move;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ed-el.is-editing .ed-el-content { cursor: text; user-select: text; overflow: auto; }
.ed-el-content img { max-width: 100%; display: block; }
.ed-el--image .ed-el-content { padding: 0; }
.ed-el--image img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.ed-el-title-badge {
  position: absolute; top: -20px; left: 0;
  font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--brand); font-weight: 700;
}

/* ---- Resize handles ---- */
.ed-handle {
  position: absolute;
  width: 12px; height: 12px;
  background: #fff;
  border: 2px solid var(--brand);
  border-radius: 50%;
  z-index: 60;
}
.ed-handle[data-h="nw"] { top: -7px; left: -7px; cursor: nwse-resize; }
.ed-handle[data-h="n"]  { top: -7px; left: 50%; margin-left: -6px; cursor: ns-resize; }
.ed-handle[data-h="ne"] { top: -7px; right: -7px; cursor: nesw-resize; }
.ed-handle[data-h="e"]  { top: 50%; right: -7px; margin-top: -6px; cursor: ew-resize; }
.ed-handle[data-h="se"] { bottom: -7px; right: -7px; cursor: nwse-resize; }
.ed-handle[data-h="s"]  { bottom: -7px; left: 50%; margin-left: -6px; cursor: ns-resize; }
.ed-handle[data-h="sw"] { bottom: -7px; left: -7px; cursor: nesw-resize; }
.ed-handle[data-h="w"]  { top: 50%; left: -7px; margin-top: -6px; cursor: ew-resize; }
.ed-el-delete {
  position: absolute; top: -14px; right: -14px;
  width: 24px; height: 24px; z-index: 61;
  border: 0; border-radius: 50%;
  background: #b00020; color: #fff; font-size: 0.9rem; line-height: 1; cursor: pointer;
}

/* ---- Confirm modal ---- */
.ed-confirm {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center;
  background: rgba(10, 16, 20, 0.55);
}
.ed-confirm[hidden] { display: none !important; }
.ed-confirm-box {
  width: min(420px, calc(100% - 32px));
  padding: 28px;
  background: var(--surface);
  border-radius: 10px;
  text-align: center;
}
.ed-confirm-box h3 { margin: 0 0 8px; font-size: 1.2rem; }
.ed-confirm-box p { margin: 0 0 22px; color: var(--muted); font-size: 0.92rem; }
.ed-confirm-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.ed-confirm-ok, .ed-confirm-cancel {
  min-height: 42px; padding: 0 20px;
  border: 0; border-radius: 6px; font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; color: #fff;
}
.ed-confirm-ok { background: #15a34a; }
.ed-confirm-ok:hover { background: #138a3f; }
.ed-confirm-cancel { background: #d13438; }
.ed-confirm-cancel:hover { background: #b62b2f; }

@media (max-width: 720px) {
  .ed-bar2 { flex-direction: column; }
  .ed-bar2-left, .ed-bar2-right { width: 100%; flex-wrap: wrap; }
  .ed-body { flex-direction: column; }
  .ed-side { flex: 0 0 auto; }
  .ed-canvas { width: 100%; }
}

/* ============================================================
   SPLIT PREVIEW vs. FULL-SCREEN VISUAL EDITOR (2 states)
   ============================================================ */
.admin-article-wrapper { display: flex; gap: 24px; padding: 20px; align-items: flex-start; }
#metadata-sidebar { width: 280px; flex-shrink: 0; }
#editor-canvas {
  flex-grow: 1; max-width: 900px; background: #ffffff; padding: 40px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); border-radius: 8px;
}
#editor-canvas img,
.ed-canvas img {
  max-width: 100%; height: auto; display: block; margin: 20px 0; object-fit: contain;
}

/* State 2: full-screen Canva workspace */
body.visual-editor-active #metadata-sidebar,
body.visual-editor-active .ed-side { display: none; }
body.visual-editor-active .ed-bar1,
body.visual-editor-active .ed-bar2 { position: sticky; z-index: 210; }
body.visual-editor-active .ed-bar1 { top: 0; }
body.visual-editor-active .ed-canvas { width: 100%; max-width: 1100px; }

/* Two states: toolbars appear ONLY in full-screen visual-editor mode;
   otherwise the editor is a quiet metadata + preview view. */
.ed-bar1, .ed-bar2 { display: none; }
body.visual-editor-active .ed-bar1,
body.visual-editor-active .ed-bar2 { display: flex; }
/* preview state: center the white "paper" and give it room */
.ed-body { transition: none; }
.ed-side .ed-add-btn.ed-enter-visual {
  width: 100%; margin-bottom: 8px; text-align: center;
}
.ed-side-actions { margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.ed-side-actions .btn { width: 100%; }
.ed-side-actions .btn--publish { background: #15a34a; border-color: #15a34a; color: #fff; }
.ed-side-actions .btn--publish:hover { background: #138a3f; border-color: #138a3f; color: #fff; }
.ed-side-actions .btn--del { color: #b00020; border-color: #b00020; }
.ed-side-actions .btn--del:hover { background: #b00020; color: #fff; }

/* ============================================================
   PUBLIC render of the visual-editor element layout
   (matches the editor canvas 1:1, scaled to fit the column)
   ============================================================ */
.article-canvas-wrap { position: relative; width: 100%; margin: 10px 0 24px; }
.article-canvas { position: relative; }
.ac-el { position: absolute; box-sizing: border-box; }
.ac-el--text { padding: 6px 8px; white-space: pre-wrap; word-wrap: break-word; }
.ac-el--image img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ============================================================
   ADMIN article list (cards) — header + scheduled badge
   ============================================================ */
.admin-list-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}
#article-grid .card { cursor: pointer; }
#article-grid .card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sched-badge {
  display: inline-block; font-size: 0.64rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
  color: purple; background: rgba(128, 0, 128, 0.12); border: 1px solid rgba(128, 0, 128, 0.30);
}

/* ============================================================
   GOOGLE-DOCS DOCUMENT EDITORS (homepage + „O nás")
   ============================================================ */
/* The shared .ed-bar2 toolbar is moved into this slot, so it sits
   exactly between the admin header/nav and the edited content. */
.doc-toolbar-slot { margin: 0 0 18px; }
.doc-toolbar-slot:empty { display: none; }
/* .ed-bar2 is display:none unless the fullscreen editor is active, so the
   docked toolbar has to re-assert its own display. */
.ed-bar2.is-docked {
  display: flex;
  position: sticky; top: 0; z-index: 40;
  border: 1px solid var(--line, #d9dee5); border-radius: 10px;
  background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
/* "Přidat obrázek"/"Přidat text" belong to the positioned article canvas,
   not to a document flow — the background widget beside them stays. */
.ed-bar2.is-docked .ed-add-btn { display: none; }

.doc-canvas {
  min-height: 420px; padding: 48px 56px; margin-bottom: 24px;
  background: #fff; border: 1px solid var(--line, #d9dee5); border-radius: 10px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
  font-size: 16px; line-height: 1.65; color: #1a1a1a;
  outline: none; overflow-wrap: break-word;
  background-size: cover; background-position: center;
}
.doc-canvas:focus-visible { border-color: var(--brand); }
.doc-canvas > * { margin: 0 0 0.65em; }
.doc-canvas h1 { font-size: 2rem; line-height: 1.2; }
.doc-canvas h2 { font-size: 1.5rem; line-height: 1.25; }
/* Mandatory „Téma" block */
.home-theme-block h2 { margin: 0 0 0.15em; }
.home-theme-block p { margin: 0 0 0.9em; opacity: 0.85; }

/* ---- Pinned articles ---- */
.pin-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0 14px; }
.pin-controls select { flex: 1 1 260px; min-width: 200px; padding: 9px 10px; border: 1px solid var(--line, #d9dee5); border-radius: 8px; background: #fff; }
.pin-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.pin-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line, #d9dee5); border-radius: 8px; background: #fff;
}
.pin-list li strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-num { font-variant-numeric: tabular-nums; opacity: 0.6; }
.feed-preview { margin: 8px 0 0; padding-left: 1.4em; display: grid; gap: 4px; }
.feed-preview li.is-pinned { font-weight: 700; }
.pin-badge {
  display: inline-block; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 999px; vertical-align: middle;
  color: var(--brand); background: rgba(0, 150, 214, 0.12); border: 1px solid rgba(0, 150, 214, 0.3);
}

/* ---- Team modular workspace (compact form + sidebar tools) ---- */
.team-workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px;
  padding: 16px; margin: 0 0 18px;
  border: 1px solid var(--line, #d9dee5); border-radius: 10px; background: #fbfcfd;
}
.team-form-box { display: grid; gap: 12px; align-content: start; }
.team-side {
  display: grid; gap: 10px; align-content: start;
  padding-left: 18px; border-left: 1px solid var(--line, #d9dee5);
}
.team-side .image-preview { width: 96px; height: 96px; background-size: cover; background-position: center; }
@media (max-width: 760px) {
  .team-workspace { grid-template-columns: 1fr; }
  .team-side { padding-left: 0; border-left: 0; border-top: 1px solid var(--line, #d9dee5); padding-top: 14px; }
  .doc-canvas { padding: 24px 18px; }
}

/* ---- Toolbar popovers (background + layers) ---- */
.ed-pop-wrap { position: relative; display: inline-flex; }
.ed-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  min-width: 210px; padding: 12px; display: grid; gap: 10px;
  background: #fff; border: 1px solid var(--line, #d9dee5); border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
}
.ed-pop h4 { margin: 0; font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.7; }
.ed-pop label { display: grid; gap: 5px; font-size: 0.82rem; }
.ed-pop input[type="color"] { width: 100%; height: 36px; padding: 2px; border: 1px solid var(--line, #d9dee5); border-radius: 6px; background: #fff; }
.ed-pop-actions { display: flex; justify-content: flex-end; }
.ed-layer-menu { min-width: 190px; padding: 6px; gap: 2px; }
.ed-layer-menu button {
  display: block; width: 100%; text-align: left; padding: 9px 11px;
  font: inherit; color: inherit; background: none; border: 0; border-radius: 7px; cursor: pointer;
}
.ed-layer-menu button:hover { background: rgba(0, 0, 0, 0.06); }

/* Canvas paints its background behind every element (elements get z >= 1). */
.ed-canvas { background-size: cover; background-position: center; }
.ed-canvas > .ed-el { z-index: 1; }

/* Admin-authored rich documents rendered on the public site */
.page-doc { margin: 0 0 28px; }
.page-doc:empty { display: none; }
.page-doc > * { margin: 0 0 0.65em; }
.page-doc h1 { font-size: 2rem; line-height: 1.2; }
.page-doc h2 { font-size: 1.5rem; line-height: 1.25; }
.page-doc ul, .page-doc ol { padding-left: 1.5em; }
.page-doc .home-theme-block p { opacity: 0.85; }
/* Admin-set page backgrounds need breathing room around the content */
.page[style*="background"] { padding: 18px; border-radius: 12px; }
