:root {
  --fondo: #ffffff;        /* the page */
  --carta: #fbfaf7;        /* the paper of the card fronts */
  --inchiostro: #1d1b2b;   /* text */
  --tenue: #8a8796;        /* secondary text */
  --filo: #e7e5ee;         /* hairlines */
  --accento: #3e3a8f;      /* the one accent: the card backs, the symbols, the line of the day */
  --accento-chiaro: #6a66b8; /* the lines on the card backs */
  --ombra: 30 26 70;       /* the shadows, as r g b */
  --ease-molla: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  height: 100%;
  display: grid;
  place-items: center;
  /* everything below is in em: the size follows both the width and the height of the window */
  font-size: clamp(8px, min(2.85vw, 2.7vh), 16px);
}

.reading {
  width: 30em;
  display: grid;
  justify-items: center;
  gap: 1.5em;
}

.reading__head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: .9em;
  border-bottom: 1px solid var(--filo);
}

.reading__title {
  font-family: 'Newsreader Variable', Georgia, serif;
  font-size: 1.45em;
  font-weight: 450;
  letter-spacing: -.01em;
}

.reading__date {
  font-size: .82em;
  font-weight: 560;
  font-stretch: 108%;
  letter-spacing: .03em;
  color: var(--tenue);
}

/* ---- the spread ---- */

.spread {
  display: flex;
  gap: 1.1em;
}

.slot {
  display: grid;
  justify-items: center;
  gap: .75em;
}

.slot__label {
  font-size: .78em;
  font-weight: 620;
  font-stretch: 112%;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--tenue);
}

.card {
  position: relative;
  width: 8.8em;
  aspect-ratio: 5 / 8;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  perspective: 40em;
}

.card:focus-visible { outline: none; }
.card:focus-visible .card__lift { outline: 2px solid var(--accento); outline-offset: 4px; border-radius: .8em; }

.card__shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -2%;
  height: 16%;
  border-radius: 50%;
  background: rgb(var(--ombra) / .32);
  filter: blur(.55em);
  transform-origin: 50% 50%;
}

.card__lift {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
}

.card__inner {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
}

.face {
  position: absolute;
  inset: 0;
  border-radius: .8em;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: grid;
  place-items: center;
}

.face--back {
  background: var(--accento);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .08), 0 1px 2px rgb(var(--ombra) / .2);
}

/* the fine hatch of the back: two sets of thin lines inside a hairline frame */
.face__hatch {
  position: absolute;
  inset: .55em;
  border-radius: .45em;
  border: 1px solid rgb(255 255 255 / .38);
  background:
    repeating-linear-gradient(45deg, rgb(255 255 255 / .13) 0 1px, transparent 1px .5em),
    repeating-linear-gradient(-45deg, rgb(255 255 255 / .08) 0 1px, transparent 1px .5em);
}

.face__mark {
  position: relative;
  width: 2.6em;
  fill: none;
  stroke: rgb(255 255 255 / .85);
  stroke-width: 1.2;
  background: var(--accento);
  border-radius: 50%;
  padding: .25em;
}
.face__mark circle { fill: rgb(255 255 255 / .85); stroke: none; }

.face__sheen {
  position: absolute;
  inset: -20% -60%;
  background: linear-gradient(105deg, transparent 40%, rgb(255 255 255 / .22) 50%, transparent 60%);
  transform: translateX(-60%);
  pointer-events: none;
}

.face--front {
  background: var(--carta);
  transform: rotateY(180deg);
  box-shadow: inset 0 0 0 1px var(--filo), 0 1px 2px rgb(var(--ombra) / .12);
  grid-template-rows: 1fr auto auto;
  padding: 1.1em .6em .95em;
  gap: .2em;
}

.face--front::before {
  content: '';
  position: absolute;
  inset: .45em;
  border: 1px solid color-mix(in srgb, var(--accento) 30%, transparent);
  border-radius: .5em;
  pointer-events: none;
}

.face__symbol {
  width: 4.4em;
  margin-top: .4em;
  align-self: center;
  fill: none;
  stroke: var(--accento);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.face__name {
  font-family: 'Newsreader Variable', Georgia, serif;
  font-style: italic;
  font-size: 1.12em;
  font-weight: 460;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.face__word {
  font-size: .62em;
  font-weight: 620;
  font-stretch: 112%;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accento);
}

/* ---- the line of the day ---- */

.line {
  min-height: 2.9em;
  max-width: 26em;
  text-align: center;
  text-wrap: balance;
  font-family: 'Newsreader Variable', Georgia, serif;
  font-size: 1.12em;
  line-height: 1.35;
  color: var(--inchiostro);
}

.line__hint {
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  font-size: .78em;
  font-weight: 520;
  letter-spacing: .01em;
  color: var(--tenue);
}

.line__w { display: inline-block; white-space: pre; }
.line__w--key { font-style: italic; color: var(--accento); }

/* ---- Draw again ---- */

.again {
  display: inline-flex;
  align-items: center;
  gap: .55em;
  height: 3.3em;
  padding: 0 1.35em 0 1.1em;
  border: 1px solid var(--filo);
  border-radius: 999px;
  background: var(--fondo);
  color: var(--inchiostro);
  font: inherit;
  font-size: .92em;
  font-weight: 600;
  font-stretch: 106%;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(var(--ombra) / .08), 0 6px 16px -10px rgb(var(--ombra) / .3);
  transition: border-color .25s, box-shadow .25s;
  -webkit-tap-highlight-color: transparent;
}

.again:focus-visible { outline: 2px solid var(--accento); outline-offset: 3px; }
.again[aria-disabled="true"] { cursor: default; }
.again[aria-disabled="true"] .again__label, .again[aria-disabled="true"] .again__icon { opacity: .45; transition: opacity .25s; }
.again__label, .again__icon { transition: opacity .25s; }

.again__icon {
  width: 1.25em;
  fill: none;
  stroke: var(--accento);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .again:not([aria-disabled="true"]):hover { border-color: color-mix(in srgb, var(--accento) 35%, var(--filo)); box-shadow: 0 1px 2px rgb(var(--ombra) / .1), 0 10px 22px -12px rgb(var(--ombra) / .45); }
}

@media (max-width: 360px) {
  .reading__date { display: none; }
}
