/* ── Fonts (self-hosted, SIL OFL) ─────────────────────────── */
@font-face { font-family: 'Poppins'; font-weight: 400; font-style: normal; font-display: swap; src: url('../fonts/Poppins-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Poppins'; font-weight: 500; font-style: normal; font-display: swap; src: url('../fonts/Poppins-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Poppins'; font-weight: 600; font-style: normal; font-display: swap; src: url('../fonts/Poppins-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Roboto Condensed'; font-weight: 400; font-style: normal; font-display: swap; src: url('../fonts/RobotoCondensed-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Roboto Condensed'; font-weight: 700; font-style: normal; font-display: swap; src: url('../fonts/RobotoCondensed-Bold.ttf') format('truetype'); }

/* ── Tokens (Anywhere Academy Style Guide) ────────────────── */
:root {
  color-scheme: light;
  --aa-dark: #253141;
  --aa-dark-75: #5C6470;
  --aa-dark-25: #C8CCD0;
  --aa-light: #6788B6;
  --aa-light-50: #B3C4DB;
  --aa-light-25: #D9E1ED;

  --ink: var(--aa-dark);
  --muted: var(--aa-dark-75);
  --page: #F3F5F8;
  --surface: #FFFFFF;
  --line: #E1E5EB;

  --explore: #6788B6; --explore-tint: #EDF1F7;
  --design:  #4A8C2A; --design-tint:  #EEF4EA;
  --engage:  #FB7200; --engage-tint:  #FFF3E8;
  --impact:  #FF5640; --impact-tint:  #FFF0ED;
  --reflect: linear-gradient(180deg, #6788B6 0%, #55A195 25%, #4A8C2A 45%, #FBE000 68%, #FB7200 84%, #FF5640 100%);

  --font-head: 'Poppins', system-ui, sans-serif;
  --font-body: 'Roboto Condensed', 'Arial Narrow', system-ui, sans-serif;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(37 49 65 / .06), 0 8px 24px rgb(37 49 65 / .07);
  --bar: 34px;
  --gap: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}
img { max-width: 100%; height: auto; }
a { color: var(--aa-light); text-underline-offset: 2px; }
a:hover { color: var(--aa-dark); }
:focus-visible { outline: 2px solid var(--aa-light); outline-offset: 2px; }

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgb(255 255 255 / .94);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1480px; margin: 0 auto;
  padding: 10px 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: block; flex: none; }
.brand img { display: block; height: 38px; width: auto; }
.topbar-title {
  display: flex; flex-direction: column; line-height: 1.2;
  padding-left: 20px; border-left: 1px solid var(--line);
  font-family: var(--font-head); min-width: 0;
}
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .14em; color: var(--aa-light); }
.topbar-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.save-state { font-size: 13px; color: var(--muted); margin-right: 8px; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: 500 14px/1 var(--font-head);
  padding: 10px 14px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer;
  color: var(--ink); background: transparent;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn-ghost:hover { background: var(--aa-light-25); }
.btn-primary { background: var(--aa-dark); color: #fff; }
.btn-primary:hover { background: #33435A; box-shadow: 0 4px 14px rgb(37 49 65 / .25); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-lg svg { width: 20px; height: 20px; }

/* ── Layout ────────────────────────────────────────────────── */
main { max-width: 1480px; margin: 0 auto; padding: 28px 24px 40px; }

.intro { max-width: 860px; margin-bottom: 24px; }
.intro h1 {
  font: 400 clamp(26px, 3.2vw, 38px)/1.2 var(--font-head);
  color: var(--aa-light); margin: 0 0 10px;
}
.intro p { margin: 0; font-size: 17px; color: var(--ink); }
.t-explore { color: var(--explore); }
.t-design { color: var(--design); }
.t-engage { color: #D25F00; }
.t-impact { color: #E0442F; }
.help-inline {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--aa-light); color: var(--aa-light);
  font: 600 12px/1 var(--font-head); vertical-align: 1px;
}

.card, .sheet {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Project card ──────────────────────────────────────────── */
.project { padding: 22px 24px 24px; margin-bottom: 24px; }
.project h2, .sheet-head h2 {
  font: 600 13px/1 var(--font-head);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--aa-light); margin: 0 0 16px;
}
.project-grid {
  display: grid; gap: 16px 20px;
  grid-template-columns: 1.4fr 1fr 1fr;
}
.pf { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pf-why { grid-column: 1 / -1; }
.pf label { font: 500 14px/1.3 var(--font-head); color: var(--ink); }
.pf input, .pf textarea {
  width: 100%;
  font: 400 17px/1.4 var(--font-body);
  color: var(--ink);
  background: #F7F9FC;
  border: 1px solid var(--aa-dark-25);
  border-radius: 8px;
  padding: 10px 12px;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.pf-title input { font: 500 18px/1.4 var(--font-head); }
.pf textarea { resize: vertical; min-height: 84px; }
.pf input:hover, .pf textarea:hover { border-color: var(--aa-light-50); }
.pf input:focus, .pf textarea:focus {
  outline: none; background: #fff;
  border-color: var(--aa-light);
  box-shadow: 0 0 0 3px rgb(103 136 182 / .22);
}

/* ── Canvas sheet ──────────────────────────────────────────── */
.sheet { padding: 22px 24px 28px; }
.sheet-head { text-align: center; margin-bottom: 8px; }
.sheet-head h2 { font-size: 22px; letter-spacing: .06em; color: var(--ink); margin: 0 0 4px; }
.license-line { margin: 0; font-size: 13px; color: var(--muted); }

.lxdc {
  --frame-inset: 5px;
  position: relative;
  display: grid;
  grid-template-columns:
    var(--bar) var(--gap) minmax(0, 1fr) var(--gap)
    repeat(6, minmax(0, .5fr))
    var(--gap) minmax(0, 1fr) var(--gap) var(--bar);
  grid-template-rows:
    minmax(230px, auto) var(--gap)
    minmax(230px, auto) var(--gap)
    minmax(250px, auto) var(--gap)
    minmax(130px, auto);
  padding: 18px 0;
}
/* The feedback loop line that runs around the canvas (drawn behind bars). */
.lxdc::before {
  content: ""; position: absolute; pointer-events: none;
  left: calc(var(--bar) / 2); right: calc(var(--bar) / 2);
  top: var(--frame-inset); bottom: var(--frame-inset);
  border: 1.5px solid var(--ink);
}

/* Phase bars */
.bar {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 8px 0;
  color: #fff; border: 0; border-radius: 2px;
  font: 500 15px/1 var(--font-head); letter-spacing: .02em;

}
.bar-label { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.bar .help { color: #fff; border-color: rgb(255 255 255 / .85); background: rgb(255 255 255 / .1); }
.bar .help:hover, .bar .help[aria-expanded="true"] { background: #fff; color: var(--ink); }
.bar-explore { grid-area: 1 / 1 / 2 / 2; background: var(--explore); }
.bar-design  { grid-area: 3 / 1 / 4 / 2; background: var(--design); }
.bar-engage  { grid-area: 5 / 1 / 6 / 2; background: var(--engage); }
.bar-reflect { grid-area: 1 / 14 / 8 / 15; background: var(--reflect); }
.pop-ask { margin: 10px 0 6px !important; }
/* Arrow heads on the loop line. */
.bar-explore::after, .bar-design::after, .bar-engage::after, .bar-reflect::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-bottom-width: 0; border-top: 8px solid var(--ink);
  top: -8px;
}
.bar-reflect::after { top: auto; bottom: -8px; border-top-width: 0; border-bottom: 8px solid var(--ink); border-top-color: transparent; }

/* Generic field cell */
.cell {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  min-width: 0;
  padding: 10px 12px 12px;
}
.cell-head {
  display: flex; align-items: flex-start; justify-content: center; gap: 8px;
  min-height: 26px; margin-bottom: 6px;
}
.cell-head h3 {
  margin: 0; text-align: center;
  font: 600 16px/1.25 var(--font-head); color: var(--ink);
}
.sublabel {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 12px/1 var(--font-head); letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding-top: 6px;
}
.sublabel::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--phase);
}
.sub-col { display: none; }
.cell textarea {
  flex: 1 1 auto;
  width: 100%; min-height: 70px;
  resize: none; overflow: hidden;
  font: 400 16px/1.42 var(--font-body);
  color: var(--ink);
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 6px;
  padding: 6px 8px;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.cell textarea:hover { border-color: color-mix(in srgb, var(--phase) 45%, transparent); }
.cell textarea:focus {
  outline: none; border-style: solid; border-color: var(--phase);
  background: rgb(255 255 255 / .8);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--phase) 22%, transparent);
}

/* Help (?) buttons */
.help {
  flex: none; display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--aa-light); background: #fff; color: var(--aa-light);
  font: 600 13px/1 var(--font-head); padding: 0; cursor: pointer;
  transition: background-color .15s, color .15s, transform .15s;
}
.help:hover, .help[aria-expanded="true"] { background: var(--aa-light); color: #fff; }
.help:active { transform: scale(.94); }
.cell-head .help { margin-top: 1px; }

/* Phase colours per cell */
[data-phase="explore"] { --phase: var(--explore); --tint: var(--explore-tint); }
[data-phase="design"]  { --phase: var(--design);  --tint: var(--design-tint); }
[data-phase="engage"]  { --phase: var(--engage);  --tint: var(--engage-tint); }
[data-phase="impact"]  { --phase: var(--impact);  --tint: var(--impact-tint); }

/* Environment / Organisational columns (continuous box with dashed separators) */
.col-cell { background: var(--tint); border-left: 1px solid var(--ink); border-right: 1px solid var(--ink); }
.col-cell[data-phase="explore"] { border-top: 1px solid var(--ink); }
.col-cell[data-phase="design"], .col-cell[data-phase="engage"] { border-top: 1px dashed var(--ink); }
.col-cell[data-phase="engage"] { border-bottom: 1px solid var(--ink); }
.col-cell .cell-head { justify-content: center; }
.env-explore { grid-area: 1 / 3 / 3 / 4; }
.env-design  { grid-area: 3 / 3 / 5 / 4; }
.env-engage  { grid-area: 5 / 3 / 6 / 4; }
.org-explore { grid-area: 1 / 12 / 3 / 13; }
.org-design  { grid-area: 3 / 12 / 5 / 13; }
.org-engage  { grid-area: 5 / 12 / 6 / 13; }

/* Centre boxes */
.box {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--tint);
  border: 1.5px solid var(--phase);
}
.box > .cell + .cell { border-left: 1px solid var(--phase); }
.box-explore { grid-area: 1 / 5 / 2 / 11; }
.box-design  { grid-area: 3 / 5 / 4 / 11; }
.box-engage  { grid-area: 5 / 5 / 6 / 11; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(120px, 1fr) minmax(120px, 1fr); }
.box-engage > .cell + .cell { border-left: 0; }
.box-engage .f-learning_experience { grid-column: 1 / -1; }
.box-engage .f-assessment, .box-engage .f-reflection { border-top: 1px dashed var(--phase); }
.box-engage .f-reflection { border-left: 1px dashed var(--phase) !important; }

.impact-cell {
  grid-area: 7 / 3 / 8 / 13;
  background: var(--tint);
  border: 1.5px solid var(--phase);
}

/* ── Popover ───────────────────────────────────────────────── */
.popover {
  position: absolute; z-index: 40;
  width: min(360px, calc(100vw - 24px));
  background: #fff; color: var(--ink);
  border-radius: 12px;
  border-top: 4px solid var(--pop-color, var(--aa-light));
  box-shadow: 0 2px 6px rgb(37 49 65 / .12), 0 18px 48px rgb(37 49 65 / .22);
  padding: 14px 18px 18px;
  animation: pop-in .14s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.pill {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font: 600 11px/1 var(--font-head); letter-spacing: .08em; text-transform: uppercase;
  color: #fff; background: var(--pop-color, var(--aa-light));
}
.pop-close {
  width: 30px; height: 30px; border-radius: 50%; border: 0; background: transparent;
  font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer;
}
.pop-close:hover { background: var(--aa-light-25); color: var(--ink); }
.popover h3 { font: 600 17px/1.3 var(--font-head); margin: 4px 0 8px; }
.pop-q { font: 500 15px/1.45 var(--font-head); margin: 0 0 10px; }
.pop-tip { margin: 0; font-size: 15px; color: var(--muted); }
.pop-tip strong { color: var(--ink); }
.popover ul { margin: 0 0 10px; padding-left: 18px; font: 500 14px/1.45 var(--font-head); }
.popover li + li { margin-top: 4px; }

/* ── Bottom actions, footer, toast ─────────────────────────── */
.bottom-actions { display: flex; justify-content: center; margin-top: 28px; }
.footer {
  max-width: 1480px; margin: 0 auto; padding: 8px 24px 40px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  color: var(--muted); font-size: 14px; text-align: left;
}
.footer img { width: 36px; height: 36px; flex: none; }
.footer p { margin: 0; max-width: 760px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 50; max-width: calc(100vw - 32px);
  background: var(--aa-dark); color: #fff;
  font: 500 14px/1.4 var(--font-head);
  padding: 12px 18px; border-radius: 10px;
  box-shadow: 0 10px 30px rgb(37 49 65 / .3);
}
.toast.is-error { background: #912B43; }
.noscript { padding: 24px; grid-column: 1 / -1; text-align: center; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1240px) {
  .topbar-title { display: none; }
}
@media (max-width: 1100px) {
  .btn-ghost span { display: none; }
  .btn-ghost { padding: 10px; }
  .save-state { display: none; }
}

/* Stacked canvas: phases read top to bottom. */
@media (max-width: 1023px) {
  .lxdc { display: flex; flex-direction: column; gap: 10px; padding: 0; }
  .lxdc::before { display: none; }
  .bar {
    flex-direction: row; justify-content: space-between;
    padding: 10px 14px; margin-top: 14px; border-radius: 8px;
  }
  .bar-label { writing-mode: horizontal-tb; transform: none; font-size: 16px; }
  .bar::after { display: none; }
  .bar-reflect { background: linear-gradient(90deg, #6788B6, #55A195, #4A8C2A, #FBE000, #FB7200, #FF5640); }
  .bar-reflect .bar-label { text-shadow: 0 1px 2px rgb(0 0 0 / .35); }
  .col-cell { border: 1px solid var(--ink) !important; border-radius: 6px; }
  .box, .box-engage { display: flex; flex-direction: column; border-radius: 6px; }
  .box > .cell + .cell { border-left: 0 !important; border-top: 1px solid var(--phase); }
  .box-engage .f-assessment, .box-engage .f-reflection { border-top-style: dashed; }
  .impact-cell { border-radius: 6px; margin-top: 14px; }
  .sub-col { display: inline; }
  .cell textarea { min-height: 90px; }
}
@media (max-width: 760px) {
  .topbar-inner { padding: 8px 16px; gap: 10px; }
  .brand img { height: 30px; }
  .btn-primary .btn-label { display: none; }
  .btn-primary { padding: 10px; }
  main { padding: 20px 16px 32px; }
  .project, .sheet { padding: 18px 16px 20px; }
  .project-grid { grid-template-columns: 1fr; }
  .bottom-actions .btn-label { display: inline; }
  .bottom-actions .btn { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
