/* Agadir Startups — Local Resource & Organisation pages
   Tailored to Agadir / Souss-Massa founders. Lightweight, no JS. */

:root {
  --bg: #f7faf8;
  --surface: #ffffff;
  --ink: #0e1a14;
  --muted: #4a5b54;
  --line: #e2ece6;
  --brand: #006233;          /* Official Moroccan flag green */
  --brand-dk: #004a26;
  --accent: #C1272D;         /* Official Moroccan flag red */
  --accent-dk: #8a0e22;
  --gold: #C9A227;           /* Pentagram-star gold accent */
  --white: #ffffff;
  --info: #0c4a8a;
  --code-bg: #eef5f0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1411;
    --surface: #131e19;
    --ink: #e9f2ee;
    --muted: #a6b6ae;
    --line: #1f2c25;
    --brand: #2bb56a;
    --brand-dk: #1f8c50;
    --code-bg: #182722;
  }
}

/* Explicit theme override (set by _chrome.js theme toggle) */
:root[data-theme="dark"] {
  --bg: #0c1411;
  --surface: #131e19;
  --ink: #e9f2ee;
  --muted: #a6b6ae;
  --line: #1f2c25;
  --brand: #2bb56a;
  --brand-dk: #1f8c50;
  --code-bg: #182722;
}
:root[data-theme="light"] {
  --bg: #f7faf8;
  --surface: #ffffff;
  --ink: #0e1a14;
  --muted: #4a5b54;
  --line: #e2ece6;
  --brand: #0a7a3b;
  --brand-dk: #075a2c;
  --code-bg: #eef5f0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Three.js dots background canvas, injected by _bg.js */
#as-bg-canvas { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

/* Make in-flow surfaces sit above the bg canvas with a touch of translucency */
main, .topbar { position: relative; z-index: 1; }
main { background: color-mix(in srgb, var(--bg) 78%, transparent); border-radius: 12px; }
.card, table, .callout {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(2px);
}

a { color: var(--brand-dk); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

.skip {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}
.skip:focus { left: 1rem; top: 1rem; width: auto; height: auto; padding: .5rem 1rem;
  background: var(--brand); color: #fff; border-radius: .5rem; z-index: 100; }

.topbar {
  background: linear-gradient(135deg, #006233 0%, #0e8a4a 35%, #C9A227 65%, #C1272D 100%);
  color: #fff;
  padding: .9rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.topbar a { color: #fff; text-decoration: none; font-weight: 600; }
.topbar .brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; letter-spacing: .02em; }
.topbar .brand-logo { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,.12); padding: 3px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.topbar .brand small { font-weight: 400; opacity: .85; margin-left: .35rem; }
.topbar .links a { margin-left: 1.1rem; font-size: .9rem; }
.topbar .links a:hover { text-decoration: underline; }
.topbar .links a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

main { max-width: 880px; margin: 0 auto; padding: 2.25rem 1.25rem 4rem; }

.crumb {
  font-size: .82rem; color: var(--muted); margin-bottom: .9rem;
}
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--brand-dk); text-decoration: underline; }

.eyebrow {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: .3rem .7rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}
.eyebrow.accent { background: var(--accent); }
.eyebrow.gold   { background: var(--gold); color: #2b1f00; }
.eyebrow.info   { background: var(--info); }

h1 {
  font-size: clamp(1.85rem, 1.2rem + 2.5vw, 2.6rem);
  line-height: 1.15;
  margin: 0 0 .65rem;
  color: var(--ink);
  letter-spacing: -.015em;
}
.lede {
  font-size: 1.12rem;
  color: var(--muted);
  margin: 0 0 1.6rem;
  max-width: 70ch;
}

h2 {
  font-size: 1.5rem;
  margin: 2.4rem 0 .7rem;
  letter-spacing: -.01em;
  border-left: 4px solid var(--brand);
  padding-left: .7rem;
}
h3 {
  font-size: 1.15rem;
  margin: 1.6rem 0 .4rem;
  color: var(--brand-dk);
}

p, ul, ol { margin: .55rem 0 .9rem; }
ul, ol { padding-left: 1.4rem; }
li { margin: .25rem 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card.tight { padding: .85rem 1rem; }
.card.brand { border-left: 4px solid var(--brand); }
.card.accent { border-left: 4px solid var(--accent); }
.card.info { border-left: 4px solid var(--info); }
.card.gold { border-left: 4px solid var(--gold); }

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .35rem 1rem;
  margin: .35rem 0;
}
.kv dt { font-weight: 700; color: var(--ink); }
.kv dd { margin: 0; color: var(--muted); }

.cta-row {
  display: flex; flex-wrap: wrap; gap: .6rem;
  margin: 1.3rem 0 .5rem;
}
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .65rem 1.1rem; border-radius: 999px;
  font-weight: 700; text-decoration: none;
  border: 2px solid transparent;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.10); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dk); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--brand); color: var(--brand-dk); }
.btn-ghost:hover { background: var(--brand); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dk); color: #fff; }

table {
  width: 100%; border-collapse: collapse; margin: 1rem 0;
  font-size: .94rem; background: var(--surface);
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
}
/* Make wide tables scroll horizontally on small screens instead of
   bursting the page width. Wrapping in a div would be cleaner but is
   not always possible from authored markdown — so we make the table
   itself a horizontally-scrollable block on narrow viewports. */
@media (max-width: 720px) {
  main table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  main table thead, main table tbody, main table tr { width: max-content; min-width: 100%; }
}
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--code-bg); font-weight: 700; color: var(--ink); }
tr:last-child td { border-bottom: 0; }

code, kbd, samp {
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: .9em;
  background: var(--code-bg);
  padding: .1rem .35rem;
  border-radius: 4px;
}

.callout {
  border-radius: 12px;
  padding: .9rem 1.1rem;
  margin: 1rem 0;
  border: 1px solid var(--line);
  background: var(--code-bg);
}
.callout strong { color: var(--brand-dk); }
.callout.warn { border-color: #e8c25a; background: #fff7df; color: #4a3700; }
.callout.warn strong { color: #7a5400; }
.callout.tip  { border-color: #7ad19f; background: #ebf9f1; color: #0d3a23; }
.callout.tip strong { color: var(--brand-dk); }

.checklist { list-style: none; padding-left: 0; }
.checklist li { padding-left: 1.8rem; position: relative; margin: .35rem 0; }
.checklist li::before {
  content: "☐"; position: absolute; left: 0; top: 0;
  font-size: 1.1rem; color: var(--brand);
}

footer.page {
  margin-top: 3rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-size: .82rem;
  color: var(--muted);
}
footer.page p { margin: .35rem 0; }

.tag {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--code-bg);
  color: var(--brand-dk);
  margin-right: .35rem;
}

.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

@media print {
  .topbar, .cta-row, .site-footer, .toc, .back-top, .reading-progress, .page-actions, #as-finder, .h-anchor, .nav-toggle, .theme-toggle { display: none !important; }
  main { padding: 0; background: #fff; color: #000; border-radius: 0; }
}

/* ----- shared chrome injected by _chrome.js ----- */

/* Topbar nav additions */
.topbar .nav-toggle {
  display: none;
  background: transparent; color: #fff; border: 0;
  font-size: 1.4rem; cursor: pointer; padding: .25rem .5rem;
}
.topbar .links { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.topbar .links a { margin-left: 1.1rem; font-size: .9rem; padding: .25rem 0; border-bottom: 2px solid transparent; }
.topbar .links a[aria-current="page"] { border-bottom-color: var(--gold); }
.topbar .theme-toggle {
  margin-left: 1.1rem; background: rgba(255,255,255,.15); color: #fff;
  border: 0; border-radius: 999px; padding: .3rem .55rem; cursor: pointer;
  font-size: .9rem;
}
.topbar .theme-toggle:hover { background: rgba(255,255,255,.28); }

/* "More" dropdown — mirrors the React Navbar SECONDARY menu */
.topbar .more-wrap { position: relative; margin-left: 1.1rem; display: inline-block; }
.topbar .more-toggle {
  background: rgba(255,255,255,.15); color: #fff; border: 0;
  border-radius: 999px; padding: .3rem .65rem; cursor: pointer;
  font-size: .9rem; font-weight: 600; display: inline-flex; align-items: center; gap: .25rem;
}
.topbar .more-toggle:hover { background: rgba(255,255,255,.28); }
.topbar .more-menu {
  position: absolute; right: 0; top: calc(100% + .4rem);
  min-width: 11rem; margin: 0; padding: .35rem 0; list-style: none;
  background: #fff; color: var(--ink); border: 1px solid rgba(0,0,0,.08);
  border-radius: .65rem; box-shadow: 0 12px 32px rgba(0,0,0,.18);
  z-index: 60;
}
.topbar .more-menu a {
  display: block; padding: .5rem .9rem; color: var(--ink) !important;
  font-size: .88rem; font-weight: 600; text-decoration: none;
}
.topbar .more-menu a:hover { background: rgba(0,98,51,.08); color: var(--brand-dk) !important; }
[data-theme="dark"] .topbar .more-menu { background: #1a1d23; color: #f4f5f7; border-color: rgba(255,255,255,.12); }
[data-theme="dark"] .topbar .more-menu a { color: #f4f5f7 !important; }
[data-theme="dark"] .topbar .more-menu a:hover { background: rgba(43,181,106,.18); color: #fff !important; }

@media (max-width: 720px) {
  .topbar .nav-toggle { display: inline-block; }
  .topbar .links {
    display: none; width: 100%; flex-direction: column; align-items: flex-start;
    background: var(--brand-dk); margin-top: .6rem; padding: .8rem 0; border-radius: 10px;
  }
  .topbar .links.open { display: flex; }
  .topbar .links a, .topbar .theme-toggle { margin: 0; padding: .5rem 1rem; }
  .topbar .more-wrap { margin: 0; width: 100%; }
  .topbar .more-toggle { width: 100%; justify-content: space-between; border-radius: 0; padding: .5rem 1rem; background: transparent; }
  .topbar .more-menu { position: static; width: 100%; box-shadow: none; border: 0; border-radius: 0; background: rgba(0,0,0,.18); }
  .topbar .more-menu a { color: #fff !important; padding: .5rem 1.6rem; }
  .topbar .more-menu a:hover { background: rgba(255,255,255,.08); color: #fff !important; }
}

/* Reading-time badge */
.reading-time {
  display: inline-block; margin-bottom: .8rem;
  font-size: .78rem; color: var(--muted);
  background: var(--code-bg); padding: .2rem .55rem; border-radius: 999px;
}

/* Anchor copy buttons on headings */
h2, h3 { position: relative; }
.h-anchor {
  margin-left: .5rem; background: transparent; border: 0; cursor: pointer;
  opacity: 0; transition: opacity .15s; font-size: .85em; color: var(--muted);
  padding: 0 .2rem; vertical-align: middle;
}
h2:hover .h-anchor, h3:hover .h-anchor, .h-anchor:focus { opacity: 1; }
.h-anchor.copied { color: var(--brand); opacity: 1; }

/* Auto Table of Contents */
.toc {
  position: fixed; right: max(1rem, calc((100vw - 880px) / 2 - 220px));
  top: 6rem; width: 200px; max-height: calc(100vh - 8rem); overflow: auto;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); border-radius: 12px; padding: .85rem 1rem;
  font-size: .82rem; backdrop-filter: blur(6px); z-index: 5;
}
.toc-h { font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: .68rem; color: var(--muted); margin-bottom: .4rem; }
.toc ol { margin: 0; padding-left: 1.1rem; }
.toc li { margin: .2rem 0; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--brand-dk); text-decoration: underline; }
@media (max-width: 1240px) { .toc { display: none; } }

/* Reading progress bar */
.reading-progress {
  position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 60;
  background: transparent; pointer-events: none;
}
.reading-progress span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--gold), var(--accent));
  transition: width .1s linear;
}

/* Back to top */
.back-top {
  position: fixed; right: 1rem; bottom: 4.5rem; z-index: 40;
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: var(--brand); color: #fff; font-size: 1.2rem; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.back-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-top:hover { background: var(--brand-dk); }

/* Floating page action bar */
.page-actions {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 40;
  display: flex; gap: .35rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); border-radius: 999px; padding: .35rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.12); backdrop-filter: blur(6px);
}
.page-actions button {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: transparent; font-size: 1rem; color: var(--ink);
}
.page-actions button:hover { background: var(--code-bg); }

/* Find on page */
#as-finder {
  position: fixed; top: 1rem; right: 1rem; z-index: 70;
  display: flex; align-items: center; gap: .4rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: .35rem .6rem;
  box-shadow: 0 8px 22px rgba(0,0,0,.18);
}
#as-finder input { border: 0; outline: 0; background: transparent; color: var(--ink); width: 14rem; font-size: .9rem; }
#as-finder .count { font-size: .75rem; color: var(--muted); min-width: 4rem; }
#as-finder button { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 1rem; }
mark.as-find { background: var(--gold); color: #2b1f00; padding: 0 .15rem; border-radius: 3px; }

/* Toast */
.as-toast {
  position: fixed; left: 50%; bottom: 6rem; transform: translate(-50%, 8px);
  background: var(--brand-dk); color: #fff; padding: .55rem 1rem;
  border-radius: 999px; font-size: .85rem; z-index: 80;
  opacity: 0; transition: opacity .2s, transform .2s;
}
.as-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Site footer */
.site-footer {
  position: relative; z-index: 1;
  margin-top: 3rem;
  background: linear-gradient(135deg, var(--brand-dk) 0%, #052b16 100%);
  color: #d6e8de; padding: 2.5rem 1.25rem 1.25rem;
}
.ft-grid {
  max-width: 1100px; margin: 0 auto;
  display: grid; gap: 1.6rem;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
}
@media (max-width: 820px) { .ft-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .ft-grid { grid-template-columns: 1fr; } }
.ft-brand { font-weight: 800; font-size: 1.15rem; color: #fff; margin-bottom: .35rem; }
.ft-tag { font-size: .85rem; color: #b5d2c3; margin: 0; }
.site-footer h4 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--gold); margin: 0 0 .5rem;
}
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: .25rem 0; }
.site-footer a { color: #e8f3ec; text-decoration: none; font-size: .88rem; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.ft-bottom {
  max-width: 1100px; margin: 1.6rem auto 0; padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
  text-align: center; color: #b5d2c3;
}
.ft-bottom small { font-size: .78rem; }
