:root {
  --natt-djup: #0b1430;
  --sno: #f3f6fb;
  --julrod: #a81c26;
  --julrod-mork: #8f1820;
  --guld: #dcae45;
  --gran: #1f5a3c;
  --tavla: #16130c;
  --lysdiod: #ffb300;
  --papper: #f6ecd2;
  --kol: 4;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--julrod-mork);
  color: var(--sno);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  display: flex;
  justify-content: center;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; }

/* The card: red board, gold line, the picture inside. It fills the screen
   up to a width where the doors would drift apart. */
.kalender {
  width: min(100%, 84rem);
  min-height: 100dvh;
  padding:
    max(.7rem, env(safe-area-inset-top))
    max(.7rem, env(safe-area-inset-right))
    max(.7rem, env(safe-area-inset-bottom))
    max(.7rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.08), transparent 40%),
    var(--julrod);
}
.huvud {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .3rem .3rem .7rem;
}
/* The one-row header under trial (?huvud=c, design/DECISIONS.md): on a
   phone the promise leaves the header and the mark shrinks, so the picture
   gets the room. */
@media (max-width: 36rem) {
  .huvud-c .huvud { padding-bottom: .5rem; gap: .6rem; }
  .huvud-c .marke { width: 2.75rem; height: 2.75rem; }
  .huvud-c .huvud .lofte { display: none; }
  .huvud-c .huvud .knapp { min-height: 2.75rem; padding: 0 1.1rem; }
}

/* HL's mark: the letters on square wheels. */
.marke { flex: none; width: 3.2rem; height: 3.2rem; }
.titel { flex: 1; min-width: 0; }
/* Who is speaking: the authority's name, as on its letterhead. */
.huvud .avsandare {
  margin: 0 0 .15rem;
  font: 700 clamp(.8rem, .72rem + .35vw, 1rem)/1.2 "Helvetica Neue", Arial, sans-serif;
  letter-spacing: .02em;
  color: var(--sno);
}
.huvud h1 {
  margin: 0;
  /* Gold on the red is 3.6:1: large text only, so never under 24px. */
  font-size: clamp(1.5rem, 1rem + 2.2vw, 2.6rem);
  line-height: 1.05;
  font-weight: 400;
  font-style: italic;
  color: var(--guld);
  text-shadow: 0 1px 0 rgba(0,0,0,.35);
}
.huvud p {
  margin: .15rem 0 0;
  font-size: clamp(.95rem, .85rem + .4vw, 1.15rem);
  color: #f7d9d2;
}

.bild {
  position: relative;
  /* Grows to fill the screen, never shrinks below its doors. */
  flex: 1 0 auto;
  border: 2px solid var(--guld);
  outline: 1px solid rgba(220,174,69,.5);
  outline-offset: 3px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--natt-djup);
  display: grid;
}
.scen {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}

/* Door 24 takes four cells, so 27 cells in all. main.js picks the number of
   columns that makes the cells closest to square for the picture's shape
   (--kol) and says how wide a cell is (--cell); 4 columns until it has. */
.luckor {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--kol), 1fr);
  grid-auto-rows: minmax(4.4rem, 1fr);
  grid-auto-flow: dense;
  padding: .5rem;
  --cell: 5.4rem;
}

/* A door is placed inside its cell with plain percentages of the cell, both
   ways. No aspect-ratio, no percentage max-height and no container units:
   WebKit sized those from the cell's height and the doors grew over each
   other (the owner's Safari, 2026-12-01). */
.lucka {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  min-width: 0;
  perspective: 600px;
  -webkit-tap-highlight-color: transparent;
}
.lucka.stor { grid-column: span 2; grid-row: span 2; }
.lucka .ram {
  position: absolute;
  left: var(--x, 14%);
  top: var(--y, 14%);
  width: var(--w, 72%);
  height: var(--h, 72%);
  transform-style: preserve-3d;
}
.lucka .inne {
  position: absolute; inset: 0;
  background: var(--papper);
  box-shadow: inset 0 0 .6rem rgba(60,30,0,.55);
  display: grid; place-items: center;
  font-size: calc(var(--cell) * .34);
  line-height: 1;
  opacity: 0;
}
.lucka.stor .inne { font-size: calc(var(--cell) * .7); }
.lucka .blad {
  position: absolute; inset: 0;
  transform-origin: left center;
  transition: transform .7s cubic-bezier(.3,.1,.2,1);
  transform-style: preserve-3d;
}
/* The flap's two sides. Which one shows is switched as the flap passes its
   edge-on moment, with no backface-visibility: engines disagree on it. */
.lucka .fram, .lucka .bak {
  position: absolute; inset: 0;
  transition: opacity 0s .27s;
}
.lucka .bak { opacity: 0; }
.lucka.oppen .bak { opacity: 1; }
.lucka.oppen .fram { opacity: 0; }
.lucka .fram {
  /* Opaque, so the number reads the same over sky, windows and snow. */
  border: 2px solid var(--guld);
  background: var(--natt-djup);
  display: grid; place-items: center;
  font-size: clamp(1.2rem, calc(var(--cell) * .3), 3.2rem);
  color: var(--guld);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.lucka.stor .fram { font-size: clamp(2rem, calc(var(--cell) * .58), 6rem); }
.lucka .bak {
  transform: rotateY(180deg);
  background: #cdbf9b;
  box-shadow: inset 0 0 .5rem rgba(60,30,0,.4);
}
.lucka.idag .fram {
  border-width: 3px;
  background: #3a3220;
  animation: glod 2.4s ease-in-out infinite;
}
@keyframes glod {
  50% { box-shadow: 0 0 1.1rem .15rem rgba(220,174,69,.85); }
}
.lucka.last { cursor: default; }
/* A locked door is dashed, not dimmed: it can still be pressed. */
.lucka.last .fram { border-style: dashed; border-width: 1.5px; }
.lucka.oppen .inne { opacity: 1; }
.lucka.oppen .blad { transform: rotateY(-152deg); }
.lucka:focus-visible { outline: none; }
.lucka:focus-visible .ram { outline: 3px solid var(--sno); outline-offset: 3px; }
.lucka.skaka .ram { animation: skaka .35s; }
@keyframes skaka {
  25% { translate: -4px 0; } 50% { translate: 4px 0; } 75% { translate: -2px 0; }
}

.fot {
  padding: .5rem .3rem 0;
  font-size: .875rem;
  line-height: 1.4;
  color: #f1c9c1;
  display: flex; flex-wrap: wrap; align-items: center; gap: .1rem 1rem;
}
.fottext { flex: 1 1 11rem; }
.fotlankar { display: flex; gap: .6rem; flex: none; }
.fot a, .textknapp {
  color: var(--sno);
  font: inherit;
  text-decoration: underline;
  background: none; border: 0; cursor: pointer;
  min-height: 2.75rem; min-width: 2.75rem;
  display: inline-grid; place-items: center;
  padding: 0 .2rem;
}
.fot a:focus-visible, .textknapp:focus-visible, .kort a:focus-visible { outline: 3px solid var(--sno); outline-offset: 2px; }

/* Share the calendar: the code, the address, two buttons. */
.kort {
  background: var(--papper);
  color: #1a1a19;
  border: 2px solid var(--guld);
  border-radius: .5rem;
  padding: 1rem 1rem .8rem;
  text-align: center;
  box-shadow: 0 1.2rem 3rem rgba(0,0,0,.6);
}
.kort h2 { margin: 0 0 .7rem; font-size: 1.35rem; font-weight: 400; font-style: italic; }
.kort img { display: block; width: min(100%, 15rem); height: auto; margin: 0 auto; background: #fff; }
.kort .adress { margin: .6rem 0 0; font: 700 1.05rem/1.3 "Helvetica Neue", Arial, sans-serif; }
#dela-ruta { width: min(92vw, 22rem); }
#om-ruta { width: min(92vw, 26rem); }
.kort.om { text-align: left; }
.kort.om p { margin: 0 0 .8rem; font-size: 1rem; line-height: 1.55; }
.kort a { color: #7a1019; }
.kort a:focus-visible { outline-color: #1a1a19; }
.reglage {
  display: flex; gap: .7rem; align-items: flex-start;
  padding-top: .8rem; border-top: 1px solid rgba(26,26,25,.25);
  font: .9rem/1.45 "Helvetica Neue", Arial, sans-serif;
  cursor: pointer;
}
.reglage input { flex: none; width: 1.5rem; height: 1.5rem; margin: .1rem 0 0; accent-color: var(--gran); }
.reglage b { display: block; }

/* The board's message is written out like a sign coming on. The whole text
   is laid out from the start, so the board never changes size while it
   writes (playbook conventions/stable-frame.md). */
.oskriven { visibility: hidden; }
.las { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* The board comes out of its door: the dialog moves as one piece and the
   backdrop dims with it (main.js enter(), the same 320 ms and easing). */
dialog.kommer::backdrop { animation: skymning 320ms cubic-bezier(.2,.8,.2,1); }
@keyframes skymning { from { opacity: 0; } }

/* The message: a departure board. */
dialog {
  border: 0; padding: 0;
  background: none;
  color: inherit;
  width: min(92vw, 34rem);
  max-height: 92dvh;
  overflow: auto;
}
dialog::backdrop { background: rgba(6,10,25,.78); }
.tavla {
  background: var(--tavla);
  border: .45rem solid #2c2a26;
  border-radius: .5rem;
  box-shadow: 0 1.2rem 3rem rgba(0,0,0,.6), inset 0 0 0 1px #000;
  padding: 1.1rem 1.1rem 1.2rem;
  font-family: "Courier New", ui-monospace, Menlo, monospace;
  color: var(--lysdiod);
  text-shadow: 0 0 .5rem rgba(255,179,0,.55);
}
.tavla .rad {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: .85rem;
  padding-bottom: .6rem;
  border-bottom: 1px dotted rgba(255,179,0,.45);
}
.tavla h2 {
  margin: .9rem 0 .5rem;
  font-size: clamp(1.3rem, 1.1rem + .8vw, 1.6rem);
  line-height: 1.2;
  font-weight: 700;
}
.tavla p {
  margin: 0;
  font-size: clamp(1.05rem, .95rem + .4vw, 1.2rem);
  line-height: 1.5;
  font-weight: 700;
}
.knappar {
  display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end;
  margin-top: .8rem;
}
.knapp {
  min-height: 2.9rem;
  padding: 0 1.3rem;
  border-radius: 1.5rem;
  border: 2px solid var(--guld);
  background: var(--julrod);
  color: var(--sno);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  display: inline-grid; place-items: center;
  text-decoration: none;
}
.knapp.stang { background: transparent; }
.huvud .knapp { flex: none; }
.knapp.lank { background: var(--gran); margin-right: auto; }
.knapp[hidden] { display: none; }
.knapp:focus-visible { outline: 3px solid var(--sno); outline-offset: 2px; }

.besked {
  position: fixed;
  /* At the top, clear of the thumbs (playbook contracts/thumb.md). */
  left: 50%; top: max(1rem, env(safe-area-inset-top));
  transform: translateX(-50%);
  background: var(--natt-djup);
  color: var(--sno);
  border: 1px solid var(--guld);
  border-radius: 1.5rem;
  padding: .6rem 1.1rem;
  font-size: .95rem;
  width: max-content;
  max-width: min(84vw, 22rem);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 10;
}
.besked.syns { opacity: 1; }

/* Snow over the whole page, on purpose a bit much. It lies over everything
   and takes no presses; under reduced motion the flakes stand still. */
.sno {
  position: fixed; inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}
.sno span {
  position: absolute;
  top: -2rem;
  color: #fff;
  text-shadow: 0 0 .25rem rgba(120,160,255,.7);
  will-change: transform;
  animation: fall linear infinite, vaj ease-in-out infinite alternate;
}
@keyframes fall { to { translate: 0 calc(100dvh + 4rem); } }
@keyframes vaj { from { margin-left: -1.2rem; rotate: -40deg; } to { margin-left: 1.2rem; rotate: 40deg; } }

@media (prefers-reduced-motion: reduce) {
  .lucka .blad, .lucka .fram, .lucka .bak { transition: none; }
  .lucka.idag .fram, .lucka.skaka .ram { animation: none; }
  .sno span { animation: none; top: var(--still); }
}
