/* ---------------------------------------------------------------------------
 * retiro.ph play — the shell's own styles
 *
 * This sheet is written for the play shell alone; it borrows nothing from the
 * site's own sheet, because the villa wants a different palette from the
 * receipt paper the rest of retiro.ph is printed on.
 *
 * The colours below are the ones the style lock names: ivory linen, Tyrian
 * purple, veined marble, aged gold, olive green and pool blue.
 *
 * Two words are kept out of this file on purpose. The word for the CSS
 * property that composes a move is not used anywhere: every move is written
 * with the standalone translate, rotate and scale properties instead. And the
 * word the site brief bans in copy is not used either.
 * ------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --ivory: #f4f1e8;
  --ivory-deep: #e7e0d2;
  --marble: #ddd6c8;
  --ink: #241f1a;
  --ink-soft: #574c3f;

  --purple: #6b2a4a;
  --purple-deep: #4d1d35;
  --gold: #a8813f;
  --olive: #5f6b46;
  --pool: #3f7387;

  --ground: var(--ivory);
  --plate: #fbf9f3;
  --plate-edge: rgba(36, 31, 26, 0.16);
  --text: var(--ink);
  --text-soft: var(--ink-soft);
  --rule: rgba(36, 31, 26, 0.2);
  --rule-soft: rgba(36, 31, 26, 0.1);
  --chip: rgba(36, 31, 26, 0.04);
  --veil: rgba(244, 241, 232, 0.92);
  --veil-soft: rgba(244, 241, 232, 0.72);
  --scrim: rgba(24, 18, 14, 0.55);
  --focus: #1d4f7a;

  --font-body: 'Source Serif 4', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --font-note: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --tab-h: 3.4rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #1b1613;
    --plate: #221c18;
    --plate-edge: rgba(240, 233, 220, 0.16);
    --text: #f0e9dc;
    --text-soft: #c6b9a6;
    --rule: rgba(240, 233, 220, 0.22);
    --rule-soft: rgba(240, 233, 220, 0.1);
    --chip: rgba(240, 233, 220, 0.06);
    --veil: rgba(27, 22, 19, 0.92);
    --veil-soft: rgba(27, 22, 19, 0.72);
    --scrim: rgba(8, 6, 5, 0.62);
    --focus: #8fc4e8;
    --purple: #b4748f;
    --gold: #c39c58;
    --olive: #97a377;
    --pool: #7fb2c4;
  }
}

/* ---------------------------------------------------------------- the floor */

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.hint {
  margin: 0.15rem 0 0.5rem;
  color: var(--text-soft);
  font-size: 0.85rem;
  line-height: 1.45;
}

/* ---------------------------------------------------------------- the way in */

.skip {
  position: fixed;
  left: 0.5rem;
  top: -4rem;
  z-index: 90;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--plate);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  transition: top 140ms ease-out;
}

.skip:focus {
  top: 0.5rem;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 80;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background: var(--ground);
  color: var(--text-soft);
  font-size: 1rem;
  text-align: center;
}

.boot[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- the top bar */

.top {
  grid-row: 1;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  padding: 0.55rem clamp(0.7rem, 3.5vw, 1.6rem) 0.65rem;
  border-bottom: 1px solid var(--rule-soft);
  background: linear-gradient(180deg, var(--veil) 0%, var(--veil-soft) 78%, transparent 100%);
}

.brand {
  margin: 0;
  flex: 1 1 9rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-who {
  color: var(--purple);
  font-family: var(--font-note);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.brand-note {
  color: var(--text-soft);
  font-size: 0.78rem;
  line-height: 1.35;
}

.stats {
  margin: 0;
  flex: 0 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.85rem;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat dt {
  color: var(--text-soft);
  font-family: var(--font-note);
  font-size: 0.62rem;
  letter-spacing: 0.09em;
}

.stat dd {
  margin: 0;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.top-next {
  margin: 0;
  flex: 1 1 100%;
  color: var(--text-soft);
  font-size: 0.75rem;
}

/* ---------------------------------------------------------------- the stage */

.stage {
  grid-row: 2 / 6;
  grid-column: 1;
  position: relative;
  z-index: 0;
  min-height: 10rem;
  overflow: hidden;
  background: var(--marble);
  cursor: pointer;
}

.stage-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 72% center; /* keep the senator in frame on narrow phones */
  scale: 1.08;
  translate: 0 0;
  transition: translate 16s linear, scale 16s linear;
}

.stage[data-pan='left-top'] .stage-img {
  translate: 1.6% 1.4%;
}

.stage[data-pan='right-top'] .stage-img {
  translate: -1.6% 1.4%;
}

.stage[data-pan='left-low'] .stage-img {
  translate: 1.6% -1.4%;
}

.stage[data-pan='right-low'] .stage-img {
  translate: -1.6% -1.4%;
}

.stage[data-pan='still'] .stage-img {
  translate: 0 0;
  scale: 1.01;
  transition: none;
}

.stage.no-art .stage-img {
  display: none;
}

.stage-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(24, 18, 14, 0.28) 0%, transparent 26%, transparent 52%, rgba(24, 18, 14, 0.5) 100%);
}

.stage.no-art .stage-veil {
  background: linear-gradient(160deg, var(--marble) 0%, var(--ivory-deep) 60%, var(--marble) 100%);
}

/* ---------------------------------------------------------------- the caption */

.stage-bar {
  grid-row: 3;
  grid-column: 1;
  z-index: 4;
  align-self: end;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  padding: 0.6rem clamp(0.7rem, 3.5vw, 1.6rem);
  background: var(--veil);
  border-top: 1px solid var(--rule-soft);
}

.stage-caption {
  margin: 0;
  flex: 1 1 14rem;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.4;
}

.stage-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.stage-hint {
  grid-row: 4;
  grid-column: 1;
  z-index: 4;
  margin: 0;
  padding: 0.35rem clamp(0.7rem, 3.5vw, 1.6rem) 0;
  background: var(--veil);
  color: var(--text-soft);
  font-size: 0.72rem;
}

.stage-hint[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- the tabs */

.tabs {
  grid-row: 5;
  grid-column: 1;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  min-height: var(--tab-h);
  background: var(--rule-soft);
  border-top: 1px solid var(--rule);
}

.tabs button {
  min-height: var(--tab-h);
  padding: 0.4rem 0.3rem;
  border: 0;
  background: var(--plate);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.tabs button[aria-pressed='true'] {
  background: var(--purple);
  color: var(--ivory);
}

/* ---------------------------------------------------------------- the sheets */

.panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: stretch center;
  background: var(--scrim);
}

.panel[hidden] {
  display: none;
}

.panel-inner {
  width: min(100%, 46rem);
  min-height: 100%;
  overflow-y: auto;
  padding: 1rem clamp(0.8rem, 4vw, 1.6rem) 5rem;
  background: var(--plate);
  border-inline: 1px solid var(--plate-edge);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--rule-soft);
}

.panel-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.panel-close {
  min-height: 2.2rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.panel-blurb {
  margin: 0.6rem 0 0.9rem;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.panel-result .panel-inner {
  width: min(100%, 40rem);
}

/* ---------------------------------------------------------------- the day card */

.day {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--scrim);
  cursor: pointer;
  opacity: 1;
  transition: opacity 950ms ease;
}

.day[hidden] {
  display: none;
}

.day.is-leaving {
  opacity: 0;
}

.day-frame {
  margin: 0;
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--marble);
}

.day-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 72% center;
}

.day-text {
  padding: 1rem clamp(0.9rem, 5vw, 2rem) 1.4rem;
  background: var(--plate);
  border-top: 1px solid var(--plate-edge);
}

.day-latin {
  margin: 0;
  font-family: var(--font-note);
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gold);
}

.day-festival {
  margin: 0.4rem 0 0;
  color: var(--purple);
  font-size: 0.9rem;
  font-style: italic;
}

.day-line {
  margin: 0.55rem 0 0;
  font-size: 1.02rem;
  line-height: 1.45;
}

.day-turns {
  margin: 0.4rem 0 0;
  color: var(--text-soft);
  font-family: var(--font-note);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.day-enter {
  margin-top: 1rem;
  min-height: 44px;
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--purple);
  border-radius: 999px;
  background: var(--purple);
  color: var(--ivory);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

/* ---------------------------------------------------------------- chips */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-block: 0.2rem 0.6rem;
}

.chip {
  min-height: 44px;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 140ms ease-out, border-color 140ms ease-out;
}

.chip small {
  display: block;
  color: inherit;
  font-size: 0.68rem;
  opacity: 0.75;
}

.chip[aria-pressed='true'] {
  background: var(--purple);
  border-color: var(--purple);
  color: var(--ivory);
}

.chip.is-suggested {
  border-color: var(--gold);
}

.chip.is-suggested::after {
  content: ' ·';
  color: var(--gold);
}

.chip.chip-door {
  background: var(--plate);
}

.chip.chip-begin[aria-pressed='true'],
.chip.chip-begin {
  border-color: var(--purple);
}

.chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chips-scale .chip {
  min-width: 44px;
  padding-inline: 0.4rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- the wizard */

.wizard-progress {
  margin: 0 0 0.4rem;
  color: var(--text-soft);
  font-family: var(--font-note);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.wizard-step[hidden] {
  display: none;
}

.wizard-step h3 {
  margin: 0.4rem 0 0.2rem;
  font-size: 1rem;
  font-weight: 600;
}

.ratings {
  display: grid;
  gap: 0.5rem;
}

.rating {
  padding: 0.5rem 0.6rem 0.6rem;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
}

.rating p {
  margin: 0 0 0.35rem;
}

.rating-name {
  font-size: 0.9rem;
}

.review {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.8rem;
  margin: 0.2rem 0 0.6rem;
  font-size: 0.9rem;
}

.review dt {
  color: var(--text-soft);
  font-family: var(--font-note);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding-top: 0.15rem;
}

.review dd {
  margin: 0;
}

.wizard-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.wizard-controls button {
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--plate);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.wizard-controls button#log-next,
.wizard-controls button#result-done {
  background: var(--purple);
  border-color: var(--purple);
  color: var(--ivory);
}

.wizard-controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wizard-note {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.6rem;
  border-inline-start: 3px solid var(--gold);
  background: var(--chip);
  font-size: 0.85rem;
}

.wizard-note[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- the result */

.result-note {
  margin: 0.7rem 0;
  font-size: 0.95rem;
}

.result-figures {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.2rem 0.8rem;
  margin: 0 0 0.8rem;
  font-size: 0.9rem;
}

.result-figures dt {
  color: var(--text-soft);
  font-family: var(--font-note);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding-top: 0.15rem;
}

.result-figures dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.result-block[hidden] {
  display: none;
}

.result-block h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.result-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.7rem;
}

.result-list {
  margin: 0;
  padding-inline-start: 1.1rem;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- the villa */

.villa-otium {
  margin: 0 0 0.8rem;
  font-size: 0.95rem;
}

.areas {
  display: grid;
  gap: 0.9rem;
}

.area {
  padding: 0.6rem 0.7rem 0.7rem;
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
}

.area-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.3rem 0.8rem;
}

.area-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.area-head p {
  margin: 0;
  color: var(--text-soft);
  font-family: var(--font-note);
  font-size: 0.7rem;
}

.area-text {
  margin: 0.25rem 0 0.5rem;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.bar {
  height: 4px;
  border-radius: 999px;
  background: var(--rule-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--olive);
  transition: width 320ms ease-out;
}

.steps {
  margin: 0.6rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.step {
  display: grid;
  gap: 0.15rem;
  padding-inline-start: 1.1rem;
  position: relative;
  font-size: 0.87rem;
}

.step::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 0.55rem;
  height: 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--plate);
}

.step[data-state='done']::before {
  background: var(--olive);
  border-color: var(--olive);
}

.step[data-state='running']::before {
  background: var(--pool);
  border-color: var(--pool);
}

.step[data-state='next']::before {
  background: var(--purple);
  border-color: var(--purple);
}

.step-name {
  font-weight: 600;
}

.step[data-state='waiting'] .step-name {
  color: var(--text-soft);
  font-weight: 400;
}

.step-state {
  color: var(--text-soft);
  font-size: 0.8rem;
}

.step .chip {
  justify-self: start;
  margin-top: 0.2rem;
}

/* ---------------------------------------------------------------- the album */

.album-count {
  margin: 0 0 0.5rem;
  color: var(--text-soft);
  font-family: var(--font-note);
  font-size: 0.75rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.7rem;
  margin-top: 0.6rem;
}

.card-grid-empty {
  margin: 1rem 0;
  color: var(--text-soft);
  font-size: 0.88rem;
}

/* ---------------------------------------------------------------- settings */

.setting-line {
  margin: 0.2rem 0 1rem;
  color: var(--text-soft);
  font-family: var(--font-note);
  font-size: 0.72rem;
}

.setting {
  padding: 0.6rem 0;
  border-top: 1px solid var(--rule-soft);
}

.setting h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.import {
  margin: 0.2rem 0 0;
}

.file {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--chip);
  cursor: pointer;
  font-size: 0.85rem;
}

.file input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- the card
 *
 * The card's own parts are named by play/engine/card.js: .rc-card holds a
 * .rc-body, the body holds the faces, a face holds .rc-art (the ivory back
 * picture under the painting, and the name over both) and the front also
 * holds .rc-foot with the tier letter and the level.
 *
 * A card with no painting yet carries [data-art='none'] on its .rc-art, and
 * there the name is written in the middle of the ivory back: an empty slot is
 * a card, never a broken picture.
 * ------------------------------------------------------------------------- */

.rc-card {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  perspective: 900px;
  isolation: isolate;
  cursor: pointer;
}

.rc-body {
  position: absolute;
  inset: 0;
}

.rc-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--ivory);
  backface-visibility: hidden;
  box-shadow: 0 1px 2px rgba(24, 18, 14, 0.24), 0 6px 16px rgba(24, 18, 14, 0.18);
}

.rc-card:not(.is-facedown) .rc-back {
  opacity: 0;
}

.rc-art {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.rc-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.rc-canvas-back {
  background: var(--ivory);
}

.rc-canvas-art {
  opacity: 0;
}

.rc-art[data-art='ready'] .rc-canvas-art {
  opacity: 1;
}

.rc-name {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  margin: 0;
  padding: 0.45rem 0.6rem;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.25;
  text-align: center;
  background: linear-gradient(0deg, rgba(244, 241, 232, 0.94) 0%, rgba(244, 241, 232, 0.72) 62%, rgba(244, 241, 232, 0) 100%);
}

.rc-art[data-art='none'] .rc-name {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0.8rem;
  background: none;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.rc-name-back {
  inset: auto 0 0;
  background: none;
  color: var(--ink);
}

.rc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.28rem 0.45rem;
  border-top: 1px solid rgba(36, 31, 26, 0.16);
  background: rgba(244, 241, 232, 0.97);
  color: var(--ink);
  font-family: var(--font-note);
  font-size: 0.66rem;
}

.rc-tier {
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-weight: 700;
}

.rc-tier[data-tier='common'] {
  color: #6f604a;
}

.rc-tier[data-tier='uncommon'] {
  color: #5f6b46;
}

.rc-tier[data-tier='rare'] {
  color: #3f7387;
}

.rc-tier[data-tier='legendary'] {
  color: #6b2a4a;
}

.rc-card.is-chosen .rc-face {
  outline: 3px solid var(--purple);
  outline-offset: -3px;
}

.rc-card[data-missing='1'] {
  opacity: 0.4;
}

/* the inspect lift */

.rc-lift-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

.rc-lifted {
  position: fixed;
  aspect-ratio: auto;
  z-index: 71;
  pointer-events: auto;
  cursor: pointer;
}

/* ---------------------------------------------------------------- less motion */

@media (prefers-reduced-motion: reduce) {
  .stage-img {
    transition: none;
    translate: 0 0;
    scale: 1.01;
  }

  .chip,
  .bar-fill,
  .skip,
  .day,
  .day-enter {
    transition: none;
  }
}

/* ---------------------------------------------------------------- short windows */

@media (max-height: 30rem) {
  .brand-note,
  .stage-hint {
    display: none;
  }

  .stage {
    min-height: 7rem;
  }
}

/* ---------------------------------------------------------------- wide windows */

@media (min-width: 48rem) {
  body {
    font-size: 1.05rem;
  }

  .top {
    align-items: center;
  }

  .stage-caption {
    font-size: 1.05rem;
  }
}
