@import url("/brand/fonts.css");

:root {
  color-scheme: light dark;
  --lilac: #E9D9F5;
  --peach: #FFDED1;
  --vanilla: #FFF3BC;
  --mint: #D0F0DE;
  --powder-blue: #D7E8FF;
  --blush: #F8DEF0;
  --plum: #51465D;
  --secondary-text: #756980;
  --off-white: #FFFEFC;
  --white: #FFFFFF;
  --border: #E8E0EE;
  --background: light-dark(var(--off-white), #24212C);
  --panel: light-dark(var(--white), #35313E);
  --text: light-dark(var(--plum), #F4EFFA);
  --muted: light-dark(var(--secondary-text), #D5C9DD);
  --line: light-dark(var(--border), #5E526D);
  --accent: var(--lilac);
  --action: light-dark(var(--plum), var(--lilac));
  --focus: light-dark(#73518D, #E9D9F5);
  --control-border: light-dark(#AA9BB5, #8F81A0);
  --correct-bg: light-dark(var(--mint), #304D42);
  --correct-ink: light-dark(#365F48, #C2E9D2);
  --incorrect-bg: light-dark(var(--peach), #553D43);
  --incorrect-ink: light-dark(#853F34, #FFDCD2);
  --soft-lilac: light-dark(#EFE1FA, #453950);
  --soft-peach: light-dark(var(--peach), #4B373D);
  --soft-vanilla: light-dark(var(--vanilla), #49412F);
  --soft-mint: light-dark(var(--mint), #33473F);
  --soft-blue: light-dark(var(--powder-blue), #363F54);
  --soft-blush: light-dark(var(--blush), #48394C);
  --radius: 1rem;
  --radius-small: .64rem;
  --shadow: 0 12px 32px light-dark(#51465D12, #17121C58);
  --heading-font: Outfit, "DM Sans", system-ui, sans-serif;
  --body-font: "DM Sans", system-ui, sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); font: 1rem/1.55 var(--body-font); }
body:has(#cafe-navigation:not([hidden])) {
  background: radial-gradient(ellipse at 52% 0%, light-dark(#FBF4FD, #352C40), transparent 52rem), var(--background);
}
[hidden] { display: none !important; }
.site-header {
  min-height: 4.75rem;
  padding: .8rem max(5vw, calc((100vw - 71rem) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .65rem 1.25rem;
}
.brand, .preferences { display: flex; align-items: center; gap: .65rem; }
.brand {
  color: var(--text);
  font: 650 1rem/1.12 var(--heading-font);
  text-decoration: none;
  max-width: 100%;
}
.brand::before {
  content: "";
  width: 2.4rem;
  height: 2.4rem;
  flex: 0 0 auto;
  border-radius: .66rem;
  background: var(--logo, url("/brand/logo.svg")) center / contain no-repeat;
}
:root[data-theme="dark"] { --logo: url("/brand/logo-dark.svg"); }
.brand-mark { display: none; }
.brand-name { display: grid; gap: .15rem; }
.brand-name strong { font-weight: 700; }
.brand-name small { color: var(--muted); font: 500 .8rem/1.15 var(--body-font); }
.caffi-icon {
  display: inline-block;
  width: 2.1rem;
  height: 1.6rem;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--plum);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
button, input, select, textarea { font-family: inherit; }
button, input, select, textarea { border-radius: var(--radius-small); }
.preferences :is(button, select) {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--control-border);
  min-height: 2.75rem;
  padding: .35rem .75rem;
  font-size: .875rem;
}
.preferences :is(button, select) { cursor: pointer; }
a { color: var(--action); text-underline-offset: .22em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: absolute; z-index: 2; top: .75rem; left: .75rem; padding: .7rem; color: var(--text); background: var(--panel); }

main { width: min(90%, 71rem); margin-inline: auto; padding-block: clamp(1.6rem, 5vw, 4rem) 3rem; }
h1, h2, h3, h4 { font-family: var(--heading-font); letter-spacing: -.025em; line-height: 1.13; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2.1rem, 5.25vw, 3.85rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3vw, 2.05rem); }
.intro { margin-bottom: 2rem; }
.intro p { margin-top: .65rem; color: var(--muted); font-size: clamp(1rem, 2vw, 1.16rem); }
.home-hero { text-align: center; margin-bottom: clamp(1.75rem, 4.5vw, 3.5rem); }
.home-hero h1 { font-size: clamp(2.7rem, 8vw, 5.5rem); }
.hero-logo { width: clamp(5rem, 9vw, 7rem); aspect-ratio: 1; margin: 0 auto 1.05rem; background: var(--logo, url("/brand/logo.svg")) center / contain no-repeat; }
.home-hero .tagline { margin-top: .65rem; color: var(--action); font-weight: 650; letter-spacing: .035em; }
.cafes, .game-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.cafe, .game-card {
  --card-color: var(--soft-lilac);
  --icon-color: var(--lilac);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  gap: .65rem;
  padding: clamp(1rem, 2.8vw, 1.85rem);
  text-decoration: none;
  color: var(--text);
  background: var(--card-color);
  border: 1px solid color-mix(in srgb, var(--text) 13%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.cafes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cafe { min-height: 12.8rem; }
.cafe:hover, .game-card:hover { transform: translateY(-2px); border-color: var(--action); }
.cafe h2, .game-card h3 { font-size: clamp(1.35rem, 2.4vw, 2rem); margin: 0; }
.cafe p, .game-card p { font-size: .96rem; }
.card-icon {
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 2.75rem;
  border-radius: .8rem;
  background: color-mix(in srgb, var(--icon-color) 52%, #FFFCF9);
}
.card-icon .caffi-icon { width: 2.65rem; height: 2rem; }
.cafe[data-cafe="dosbarth"], .tone-peach { --card-color: var(--soft-peach); --icon-color: var(--peach); }
.cafe[data-cafe="tgau"], .tone-blue { --card-color: var(--soft-blue); --icon-color: var(--powder-blue); }
.tone-mint { --card-color: var(--soft-mint); --icon-color: var(--mint); }
.tone-vanilla { --card-color: var(--soft-vanilla); --icon-color: var(--vanilla); }
.tone-blush { --card-color: var(--soft-blush); --icon-color: var(--blush); }
.open { display: flex; gap: .3rem; align-items: center; margin-top: auto; padding-top: .35rem; color: var(--action); font-weight: 700; font-size: .94rem; }
.open .caffi-icon { width: 1.45rem; height: 1.15rem; stroke: currentColor; stroke-width: 4; }
.cafe:hover .open span { text-decoration: underline; }
.entry-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 1rem; margin-top: 1.2rem; }
.entry-actions .entry-button, :where(main) button[type="submit"] {
  background: var(--action);
  color: light-dark(var(--white), #2A2131);
  border-color: transparent;
  border-radius: var(--radius-small);
  padding: .6rem .95rem;
  font-weight: 700;
}
.entry-actions .entry-button { background: var(--action); text-decoration: none; }
.entry-button:hover { text-decoration: underline; }
.school-check-link { margin-top: 1.5rem; font-size: .9rem; }
.preview-resources { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1.5rem; }
.preview-resources > p { margin-bottom: .85rem; font-size: .9rem; }
.preview-resources > ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: .6rem;
  list-style: none;
  padding: 0;
}
.preview-resources li a {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  display: flex;
  min-height: 2.75rem;
  padding: .6rem .85rem;
  text-decoration: none;
}
.preview-resources li a:hover { border-color: var(--action); text-decoration: underline; }
.game-section { margin: 1.8rem 0; }
.game-section h2 { margin: 0 0 .85rem; }
.game-cards { list-style: none; padding: 0; }
.game-card { height: 100%; box-shadow: none; }
.game-card .card-icon { width: 4.2rem; height: 3.05rem; }
.game-card .caffi-icon { width: 3rem; height: 2.25rem; }
.game-card h3 { font-size: 1.35rem; }

main form.caffi-auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: .9rem;
  width: min(100%, 29rem);
  margin: 1.5rem 0 2rem;
  padding: clamp(1rem, 4.5vw, 1.65rem);
  background: light-dark(var(--off-white), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-brand {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  column-gap: .8rem;
  align-items: center;
  margin-bottom: .15rem;
}
.auth-brand::before {
  content: "";
  width: 3.25rem;
  height: 3.25rem;
  grid-row: span 2;
  background: var(--logo, url("/brand/logo.svg")) center / contain no-repeat;
}
.auth-brand b { align-self: end; font: 650 1rem/1.15 var(--heading-font); }
.auth-brand small { color: var(--muted); font-size: .82rem; align-self: start; }
.caffi-auth h2 { font-size: 1.7rem; }
main form.caffi-auth :is(input, select, button) { max-width: 100%; width: 100%; }
main form.caffi-auth :is(input, select) { background: var(--panel); }
main form.caffi-auth button[type="submit"] {
  background: var(--action);
  border-color: var(--action);
  color: light-dark(var(--white), #2A2131);
}
.caffi-auth [role="status"]:empty { display: none; }
.caffi-auth [role="status"]:not(:empty), [data-feedback] {
  padding: .65rem .8rem;
  border-radius: var(--radius-small);
  background: var(--incorrect-bg);
  color: var(--incorrect-ink);
}
[data-feedback="correct"] { background: var(--correct-bg); color: var(--correct-ink); }

html body .cards a {
  border-inline-start-color: var(--action);
  border-radius: var(--radius);
  background: var(--card-color, var(--soft-lilac));
  color: var(--text);
  text-decoration: none;
}
html body .cards :is(.card-cta, a:hover strong) { text-decoration: underline; }
html body .cards a:has(.card-icon) { display: grid; grid-template-columns: 3rem minmax(0,1fr); align-items: center; column-gap: .65rem; }
.cards .card-icon { grid-row: span 2; width: 2.8rem; }
.cards .card-icon .caffi-icon { width: 2rem; }
.cards :is(small, .card-detail) { grid-column: 2; }
html body :is(#questions label, #lesson, #round, #topic-progress, #progressPanel, #journeyPanel, #classTopics, .gameSetup, .teacherControls, .topicSection) {
  border-radius: var(--radius);
}
html body :is(#lesson, #round, #topic-progress, #progressPanel, #journeyPanel, .teacherControls, .topicSection) {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: clamp(.85rem, 2.2vw, 1.35rem);
  margin-block: .8rem;
}
html body #questions label { background: var(--panel); }
html body table { border-spacing: 0; border-collapse: separate; }
html body tbody tr:nth-child(even) { background: color-mix(in srgb, var(--soft-lilac) 37%, transparent); }
html body :is(progress, input[type="range"], input[type="checkbox"], input[type="radio"]) { accent-color: var(--action); }
html body select[data-sorbet="mint"] { background: var(--soft-mint); color: light-dark(#365F48, #D5EBDD); }
html body select[data-sorbet="vanilla"] { background: var(--soft-vanilla); color: light-dark(#85632C, #FFF0BF); }
html body select[data-sorbet="peach"] { background: var(--soft-peach); color: light-dark(#994F41, #FFDCD2); }
html body select[data-sorbet="lilac"] { background: var(--soft-lilac); color: var(--text); }
html body select[data-sorbet="blue"] { background: var(--soft-blue); color: var(--text); }
html body option[data-topic="Rhif"] { background: var(--soft-lilac); }
html body option[data-topic="Algebra"] { background: var(--soft-peach); }
html body option[data-topic="Geometreg"] { background: var(--soft-blue); }
html body option[data-topic="Ystadegau"], html body option[data-topic="Ystadegaeth"] { background: var(--soft-mint); }

@media (max-width: 46rem) {
  .cafes, .game-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 35rem) {
  main { width: min(92%, 71rem); }
  .site-header { padding-inline: 4vw; }
  .cafes { grid-template-columns: 1fr; }
  .cafe { min-height: 0; }
  .game-cards { gap: .7rem; }
  .game-card { padding: .8rem; }
  .game-card h3 { font-size: 1.12rem; }
}
@media (prefers-reduced-motion: reduce) {
  .cafe, .game-card { transition: none; }
  .cafe:hover, .game-card:hover { transform: none; }
}
@media (forced-colors: active) {
  .cafe, .game-card { border: 1px solid LinkText; }
  .caffi-icon { stroke: CanvasText; }
}

html body :is(#teacherClassForm, #dashboard #group, #catalogue #selection, #practice #selection,
  #challenge #answers, #classroom-setup, #panel > #create, #panel > #join, #panel > #room,
  #game > #create, #game > #join, #revision-pdf, #booklets, #map-view, #rewards, #teacher-progress) {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: clamp(.9rem, 2.4vw, 1.35rem);
  margin-block: 1rem;
}
html body :is(#teacherClassList, #rewards) :is(article, details) {
  margin-block: .75rem;
  padding: .95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
#teacherClassList article h2 { margin-bottom: .5rem; }
#teacherClassList article button { margin: .2rem .35rem .2rem 0; }
main :is(#status, #catalogue-status):empty { display: none; }
[data-brand-loading] {
  display: flex;
  gap: .6rem;
  align-items: center;
  min-height: 2rem;
}
[data-brand-loading]::before {
  content: "";
  width: 1.8rem;
  height: 1.8rem;
  flex: 0 0 auto;
  background: var(--logo, url("/brand/logo.svg")) center / contain no-repeat;
}
#cafe-resources > ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: .65rem;
  padding: 0;
  list-style: none;
}
#cafe-resources li a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  height: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--panel);
}
html body :is(#question, #prompt, .questionText) { font-size: clamp(1rem, 2vw, 1.22rem); }
html body .questionDiagram { border-radius: var(--radius-small); }

.teacher-entry {
  margin: 1.5rem 0 0;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.teacher-entry summary {
  cursor: pointer;
  font: 650 1.2rem/1.4 var(--heading-font);
}
.teacher-entry [role="status"]:empty { display: none; }
.teacher-entry-content { margin-top: 1rem; }
.teacher-entry form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .75rem;
}
.teacher-entry form[hidden] { display: none; }
.teacher-entry form label { display: grid; gap: .3rem; }
.teacher-entry form input { min-width: 0; max-width: 100%; }
.teacher-sites {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  list-style: none;
  padding: 0;
}
.teacher-sites :is(a, button) {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: .6rem .85rem;
  color: var(--text);
  background: var(--panel);
  font: inherit;
  cursor: pointer;
}

.teacher-entry .caffi-auth :is(.auth-brand, h2) { display: none; }
.teacher-entry input {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--control-border);
  padding: .55rem .65rem;
}

.class-game {
  margin-block: 1rem 1.5rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft-peach);
}
.class-game h2 { margin: 0 0 .65rem; }
.class-game form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.class-game label { display: grid; gap: .25rem; }
.class-game input { width: 12ch; }
.class-game :is(p, ul):empty { display: none; }

.teacher-hub {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.teacher-hub .game-card {
  text-align: start;
  font-family: inherit;
  font-size: 1rem;
}
.teacher-hub button.game-card { cursor: pointer; }
.teacher-hub .game-card strong { font: 700 1.2rem/1.3 var(--heading-font); }

.class-plan {
  margin-block: 1rem 1.5rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft-mint);
}
.class-plan h2 { margin: 0 0 .65rem; }
.class-plan summary { cursor: pointer; font: 700 1.15rem/1.4 var(--heading-font); }
.class-plan fieldset { border: 0; padding: 0; margin: .75rem 0; }
.class-plan fieldset label { margin-bottom: .5rem; }
.class-plan :is(textarea, select) { width: min(100%, 32rem); }
.class-plan :is(p, ul):empty { display: none; }
.class-plan li p { margin-block: .25rem .65rem; white-space: pre-wrap; overflow-wrap: anywhere; }

.class-plan .plan-field { margin-bottom: .55rem; }
.class-plan .plan-field label { display: block; margin-bottom: .2rem; }
.class-plan .plan-check { display: flex; gap: .5rem; align-items: baseline; }
