/* Forma — a schedule you read by date. Each category carries the colour of its material. */

:root {
  --plaster: #e9ede9;
  --paper: #f7f8f5;
  --ink: #14202b;
  --slate: #4b5963;
  --line: #c5cdc8;
  --glaze: #1d4c78;
  --poppy: #f08a24;

  --c-baking: #8a5a36;
  --c-ceramics: #5b86ad;
  --c-floristry: #e9a21c;
  --c-painting: #1b9aa6;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --rail: 22rem;
  --gutter: clamp(1rem, 4vw, 3rem);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--plaster);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
}

body.is-locked { overflow: hidden; }

img { display: block; max-width: 100%; }

button, input, select { font: inherit; color: inherit; }

[hidden] { display: none !important; }

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

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--ink);
  color: #fff;
}
.skip:focus { top: 1rem; }

/* ---------- layout ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem 1.75rem 1.5rem;
  border-right: 1px solid var(--line);
}

.main {
  padding: 2rem var(--gutter) 4rem;
  max-width: 62rem;
}

/* ---------- brand ---------- */

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 4.25rem;
  line-height: .9;
  letter-spacing: -.035em;
}

.tagline {
  margin: .75rem 0 0;
  max-width: 16rem;
  color: var(--slate);
}

/* ---------- controls ---------- */

.controls { display: grid; gap: 1rem; }

.field { display: grid; gap: .3rem; }

.field label {
  font-size: .875rem;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 2.75rem;
  padding: .5rem .75rem;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 2px;
}

.field select {
  appearance: none;
  padding-right: 2.25rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 55%, calc(100% - .8rem) 55%;
  background-size: .35rem .35rem;
  background-repeat: no-repeat;
}

.field input { appearance: none; }
.field input::placeholder { color: #5a6872; }

.saved-toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .6rem;
  min-height: 2.75rem;
  padding: .5rem .75rem;
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  text-align: left;
  cursor: pointer;
}

.saved-toggle__mark {
  width: .9rem;
  height: .9rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.saved-toggle__count {
  min-width: 1.6rem;
  padding: 0 .4rem;
  border-radius: 1rem;
  background: var(--ink);
  color: #fff;
  font-size: .8125rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.saved-toggle[aria-pressed="true"] { background: var(--poppy); }
.saved-toggle[aria-pressed="true"] .saved-toggle__mark { background: var(--ink); }

.shortlist-note {
  margin: -.5rem 0 0;
  font-size: .875rem;
  color: var(--slate);
}

.rail-photo { margin: auto 0 0; }
.rail-photo img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}
.rail-photo figcaption {
  margin-top: .5rem;
  font-size: .75rem;
  line-height: 1.4;
  color: var(--slate);
}

/* ---------- list ---------- */

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: .9rem;
  border-bottom: 2px solid var(--ink);
}

.list-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
}

.result-count { margin: 0; color: var(--slate); font-size: .9375rem; }

.list { list-style: none; margin: 0; padding: 0; }

.item {
  --tone: var(--slate);
  position: relative;
  display: grid;
  grid-template-columns: 6.5rem 15rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  padding: 1.5rem 1rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--line);
  transition: background-color .15s;
}

.item::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--tone);
}

.item:hover { background: var(--paper); }
.item:has(.open-item:focus-visible) { outline: 3px solid var(--glaze); outline-offset: -3px; }

.item[data-category="Baking"]    { --tone: var(--c-baking); }
.item[data-category="Ceramics"]  { --tone: var(--c-ceramics); }
.item[data-category="Floristry"] { --tone: var(--c-floristry); }
.item[data-category="Painting"]  { --tone: var(--c-painting); }

.when { line-height: 1; }

.when__day {
  display: block;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 4.75rem;
  letter-spacing: -.04em;
  font-variant-numeric: lining-nums;
}

.when__rest {
  display: block;
  margin-top: .4rem;
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.3;
}

.item__img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--line);
}

.item__body { display: grid; gap: .5rem; min-width: 0; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .875rem;
  font-weight: 600;
}
.tag::before {
  content: "";
  width: .75rem;
  height: .75rem;
  border-radius: 50%;
  background: var(--tone);
}

.item__title { margin: 0; line-height: 1.1; }

.open-item {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.875rem;
  letter-spacing: -.015em;
  line-height: 1.1;
  text-align: left;
  cursor: pointer;
}
.open-item::after { content: ""; position: absolute; inset: 0; }
.open-item:focus-visible { outline: none; }

.item__summary {
  margin: 0;
  max-width: 34rem;
  color: #2c3944;
  line-height: 1.6;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
  margin: .25rem 0 0;
  font-size: .9375rem;
}
.facts div { display: flex; gap: .35rem; }
.facts dt { color: var(--slate); }
.facts dd { margin: 0; font-weight: 600; }

.saved-badge {
  position: absolute;
  top: 1.5rem;
  right: 1rem;
  padding: .15rem .6rem;
  background: var(--poppy);
  font-size: .8125rem;
  font-weight: 700;
  border-radius: 1rem;
}

/* ---------- empty / error ---------- */

.empty {
  padding: 3rem 0;
  max-width: 28rem;
}
.empty__title {
  margin: 0 0 .5rem;
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1.1;
}
.empty__text { margin: 0 0 1.5rem; color: #2c3944; }

.load-error { padding: 2rem 0; font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  min-height: 3rem;
  padding: .6rem 1.25rem;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}
.btn--ink { background: var(--ink); color: #fff; }
.btn--ink:hover { background: #24384a; }

/* ---------- detail sheet ---------- */

.sheet {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  padding: 0;
  width: min(64rem, 100vw);
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

.sheet::backdrop { background: rgba(20, 32, 43, .55); }

.sheet[open] { animation: sheet-in .24s ease-out; }
.sheet[open]::backdrop { animation: fade-in .24s ease-out; }

@keyframes sheet-in {
  from { transform: translateX(2.5rem); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.detail {
  --tone: var(--slate);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
}
.detail[data-category="Baking"]    { --tone: var(--c-baking); }
.detail[data-category="Ceramics"]  { --tone: var(--c-ceramics); }
.detail[data-category="Floristry"] { --tone: var(--c-floristry); }
.detail[data-category="Painting"]  { --tone: var(--c-painting); }

.detail__media { position: relative; background: var(--tone); }
.detail__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail__content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 0;
  padding: 4.75rem 2.25rem 2rem;
  overflow-y: auto;
  border-top: 8px solid var(--tone);
}

.detail__bar {
  position: absolute;
  top: 1.5rem;
  right: 2.25rem;
  z-index: 2;
}

.close-detail {
  min-height: 2.75rem;
  padding: .4rem 1rem;
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  font-weight: 700;
  cursor: pointer;
}
.close-detail:hover { background: var(--plaster); }

.detail__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2.5rem, 4.5vw, 3.5rem);
  letter-spacing: -.025em;
  line-height: 1;
}

.detail__when {
  margin: .75rem 0 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.2;
}

.detail__body {
  margin: 0;
  max-width: 34rem;
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
}

.specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-top: 2px solid var(--ink);
}
.specs div {
  padding: .75rem 0;
  border-bottom: 1px solid var(--line);
}
.specs div:nth-child(odd) { padding-right: 1rem; }
.specs dt { font-size: .875rem; color: var(--slate); }
.specs dd { margin: 0; font-size: 1.125rem; font-weight: 600; }

.detail__actions { display: grid; gap: .6rem; margin-top: auto; }

.save-item {
  min-height: 3.25rem;
  padding: .6rem 1.25rem;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: #fff;
  font-size: 1.0625rem;
  font-weight: 700;
  cursor: pointer;
}
.save-item:hover { background: #24384a; }
.save-item[aria-pressed="true"] { background: var(--poppy); color: var(--ink); }
.save-item[aria-pressed="true"]:hover { background: #f69d45; }

.save-status { margin: 0; min-height: 1.5rem; font-size: .9375rem; color: var(--slate); }

/* ---------- tablet / mobile ---------- */

@media (max-width: 64rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .rail {
    position: static;
    height: auto;
    overflow: visible;
    gap: 1rem;
    padding: 1.25rem var(--gutter) 1.25rem;
    border-right: 0;
    border-bottom: 2px solid var(--ink);
  }

  .brand { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
  .wordmark { font-size: 2.75rem; }
  .tagline { margin: 0; max-width: none; flex: 1 1 14rem; font-size: .9375rem; }

  .controls { grid-template-columns: 1fr 1fr; }
  .controls .field:first-child { grid-column: 1 / -1; }
  .saved-toggle { align-self: end; }

  .shortlist-note { margin-top: 0; }
  .rail-photo { display: none; }

  .main { padding-top: 1.25rem; max-width: none; }
}

@media (max-width: 56rem) {
  .item {
    grid-template-columns: 4.25rem minmax(0, 1fr);
    gap: .9rem 1rem;
    padding: 1.1rem .75rem 1.25rem 1rem;
  }
  .item::before { width: 5px; }
  .item__img { grid-column: 1 / -1; aspect-ratio: 16 / 9; order: -1; }
  .when__day { font-size: 3.25rem; }
  .when__rest { font-size: .8125rem; }
  .open-item { font-size: 1.625rem; }
  .saved-badge { top: 1.1rem; right: .75rem; }
  .item__summary { font-size: .9375rem; }

  .sheet { width: 100vw; }
  .detail {
    display: block;
    grid-template-rows: none;
    height: 100%;
    overflow-y: auto;
  }
  .detail__media { height: 13rem; }
  .detail__media::after { content: none; }
  .detail__content {
    overflow: visible;
    padding: 1.25rem var(--gutter) 2rem;
    border-top: 0;
  }
  .detail__bar {
    position: sticky;
    top: 0;
    right: auto;
    display: flex;
    justify-content: flex-end;
    padding: .6rem var(--gutter);
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }
  .detail__actions {
    position: sticky;
    bottom: 0;
    margin: 0 calc(var(--gutter) * -1) -2rem;
    padding: .75rem var(--gutter) 1rem;
    background: var(--paper);
    border-top: 1px solid var(--line);
  }
  .save-status { display: none; }
}

@media (max-width: 26rem) {
  .controls { gap: .75rem; }
  .saved-toggle { gap: .5rem; padding: .5rem; }
  .rail { gap: .75rem; }
  .shortlist-note { font-size: .8125rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet[open], .sheet[open]::backdrop { animation: none; }
  .item { transition: none; }
}
