/* Urări de bine — stylesheet
   Leather cover around, a yellowed paper leaf in the middle, iron-gall ink and cinnabar. */

:root {
  --leather: #2a1d14;
  --paper: #efe0bf;
  --paper-shadow: #c9ab6e;
  --ink: #2b1a10;
  --ink-2: #5a4130;
  --red: #a3271c;      /* cinnabar, for initials and rubrics */
  --red-dark: #7c1a12;
  --gold: #c9a24d;
  --gold-pale: #e6cf8f;
  --focus: #f2c14e;
  --focus-paper: #8a5a00; /* dark gold: visible on paper (5.3:1), where #f2c14e would not be */

  --f-title: "Grenze Gotisch", "UnifrakturMaguntia", Georgia, serif;
  --f-hand: "Kurale", "Alegreya", Georgia, serif;
  --f-text: "Alegreya", Georgia, "Times New Roman", serif;
  --f-code: "Courier Prime", "Courier New", monospace;

  --radius: 4px;
  --card-shadow: 0 1px 0 #fff6 inset, 0 30px 60px -20px #000c, 0 12px 24px -12px #000a;
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; overflow-x: clip; }

/* Navigation between pages: a short fade instead of a jump */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* The saved language is applied before first paint (script in <head>); without JS, the text shows after 2 s */
html.i18n-pending body { visibility: hidden; animation: i18n-fallback 0s 2s forwards; }
@keyframes i18n-fallback { to { visibility: visible; } }
/* coming from another page of the site, the entrance animations do not repeat */
.returning .header__title, .returning .header__desc, .returning .altar { animation: none; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--f-text);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--gold-pale);
  background-color: var(--leather);
  background-image:
    radial-gradient(ellipse at 50% -10%, #6b4a2c55, transparent 60%),
    radial-gradient(ellipse at 50% 120%, #00000080, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  overflow-x: clip;
}

a { color: inherit; }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; margin: -1px; padding: 0; border: 0;
}


.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 50;
  background: var(--paper); color: var(--ink);
  padding: .5rem 1rem; border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; }

code { font-family: var(--f-code); font-size: .92em; }

/* ---------- Header ---------- */

.header {
  max-width: 46rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 1.5rem;
  text-align: center;
}

.header__eyebrow {
  margin: 0 0 1rem;
  font-size: .8rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .85;
}

.header__title {
  margin: 0;
  font-family: var(--f-title);
  font-weight: 900;
  font-size: clamp(2.6rem, 11vw, 5.4rem);
  line-height: .95;
  color: var(--paper);
  text-shadow: 0 2px 0 #0008, 0 0 40px #c9a24d33;
  animation: rise-in 1.2s cubic-bezier(.2,.7,.2,1) both;
}

.header__small {
  display: block;
  font-family: var(--f-text);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(.95rem, 3.6vw, 1.25rem);
  letter-spacing: .04em;
  color: var(--gold);
  text-shadow: none;
  margin: .5rem 0;
}

.header__desc {
  margin: 1.25rem auto 0;
  max-width: 36rem;
  color: #e9d9b4;
  font-size: 1.05rem;
  animation: rise-in 1.2s .25s cubic-bezier(.2,.7,.2,1) both;
}
.header__desc strong { color: var(--paper); }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* ---------- Altar: settings + buttons ---------- */

.altar {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
  animation: rise-in 1.2s .45s cubic-bezier(.2,.7,.2,1) both;
}

/* Level + theme: one compact row under the buttons (two narrow rows on a phone) */
.settings {
  display: grid;
  gap: .7rem;
  margin: 0 0 2.25rem;
}

.level { border: 0; margin: 0; padding: 0; min-width: 0; }
.level legend, .theme label {
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: .3rem;
  padding: 0;
}

.level__options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid #c9a24d66;
  border-radius: 999px;
  overflow: hidden;
  background: #00000033;
}

.level__option { position: relative; cursor: pointer; }
.level__option + .level__option { border-left: 1px solid #c9a24d44; }
.level__option input {
  position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer;
}
.level__option span {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 2.5rem;
  padding: .3rem .6rem;
  text-align: center;
  transition: background .2s, color .2s;
}
.level__option b { font-weight: 700; font-size: .98rem; color: var(--paper); }
.level__option small { display: none; font-size: .72rem; font-style: italic; color: #d8c391; line-height: 1.15; }
@media (min-width: 640px) { .level__option small { display: block; } }
.level__option:hover span { background: #c9a24d1a; }
.level__option input:checked + span { background: var(--paper); }
.level__option input:checked + span b { color: var(--ink); }
.level__option input:checked + span small { color: var(--ink-2); }
.level__option input[value="vulgar"]:checked + span { background: var(--red); }
.level__option input[value="vulgar"]:checked + span b,
.level__option input[value="vulgar"]:checked + span small { color: var(--paper); }
.level__option input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

.theme { display: grid; }
.theme select {
  appearance: none;
  font: inherit;
  color: var(--paper);
  background: #00000040 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23c9a24d' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right .9rem center;
  border: 1px solid #c9a24d66;
  border-radius: var(--radius);
  padding: .4rem 2.2rem .4rem .8rem;
  min-height: 2.5rem;
}
.theme select option { color: var(--ink); background: var(--paper); }

@media (min-width: 640px) {
  .settings { grid-template-columns: auto minmax(12rem, 16rem); justify-content: center; align-items: end; gap: .7rem 1.25rem; }
  .level__note { grid-column: 1 / -1; }
  .theme select { height: 100%; min-height: 2.9rem; }
}

.main-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .9rem;
  margin: 1.75rem 0 1.5rem;
}

.main-button {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: .7rem;
  width: auto;
  min-width: min(100%, 22rem);
  max-width: 100%;
  white-space: nowrap;
  padding: 1.05rem 1.75rem 1.15rem;
  font-family: var(--f-title);
  font-weight: 700;
  font-size: clamp(1.3rem, 6vw, 2.3rem);
  line-height: 1;
  color: var(--paper);
  background:
    radial-gradient(circle at 30% 25%, #d4473a, transparent 55%),
    linear-gradient(180deg, var(--red), var(--red-dark));
  border: 0;
  border-radius: 999px;
  box-shadow:
    0 0 0 3px var(--leather), 0 0 0 4px var(--gold),
    0 2px 0 #ffffff33 inset, 0 -4px 0 #00000040 inset,
    0 18px 30px -12px #000;
  cursor: pointer;
  text-shadow: 0 2px 0 #0006;
  transition: transform .15s ease, box-shadow .2s, filter .2s;
}
.main-button:hover { transform: translateY(-2px) rotate(-1deg); filter: brightness(1.08); }
.main-button:active { transform: translateY(1px) scale(.98); }
.main-button[aria-busy="true"] { filter: saturate(.6) brightness(.9); cursor: progress; }
.main-button:focus-visible { outline-offset: 8px; }
.main-button__seal {
  font-family: var(--f-text);
  font-size: .75em;
  color: var(--gold-pale);
  transition: transform .6s cubic-bezier(.3,1.6,.5,1);
}
.main-button:hover .main-button__seal { transform: rotate(180deg); }

/* "...or make one up on the spot!": the continuation of the red button, not a boxed button */
.secondary-button {
  font: italic 500 1.15rem var(--f-text);
  color: var(--gold-pale);
  background: none;
  border: 0;
  border-radius: 999px;
  min-height: 2.75rem;
  padding: .35rem 1rem;
  cursor: pointer;
  text-decoration: underline dotted transparent; text-underline-offset: 5px; text-decoration-thickness: 1.5px;
  transition: color .2s, text-decoration-color .2s;
}
.secondary-button:hover, .secondary-button:focus-visible { color: var(--paper); text-decoration-color: var(--gold); }
.secondary-button:active { transform: translateY(1px); }
.secondary { display: grid; justify-items: center; gap: 0; text-align: center; margin-top: -.35rem; }
.small-note { margin: 0; font-size: .9rem; font-style: italic; color: #d8c391; max-width: 28rem; }

.level__note { margin: 0; text-align: center; font-size: .84rem; font-style: italic; color: #d8c391; }

/* ---------- The card ---------- */

.card {
  position: relative;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 15% 10%, #ffffff55, transparent 45%),
    radial-gradient(ellipse at 90% 95%, #a0782f40, transparent 50%),
    radial-gradient(ellipse at center, transparent 55%, #a57c3a55 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.04 .9' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .32 0 0 0 0 .15 0 0 0 .18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
  border-radius: 3px 6px 4px 3px;
  box-shadow: var(--card-shadow);
  padding: 2.25rem 1.5rem 1.5rem;
  min-height: 0;
  outline: none;
  transform-origin: 50% 0;
  isolation: isolate;
}
.card:focus-visible { outline: 3px solid var(--focus); outline-offset: 6px; }

.card::before { /* working margin, like on a manuscript */
  content: "";
  position: absolute; inset: .75rem;
  border: 1px solid #7a5a3355;
  border-radius: 2px;
  pointer-events: none;
}

.card__corner {
  position: absolute; width: 3.2rem; height: 3.2rem;
  color: var(--ink-2);
  opacity: .8;
  pointer-events: none;
}
.card__corner--tl { top: .35rem; left: .35rem; }
.card__corner--tr { top: .35rem; right: .35rem; transform: scaleX(-1); }
.card__corner--bl { bottom: .35rem; left: .35rem; transform: scaleY(-1); }
.card__corner--br { bottom: .35rem; right: .35rem; transform: scale(-1); }

.card__head { text-align: center; }
.card__day {
  margin: .6rem 0 0;
  font-size: .78rem; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--red);
}
.card__day[hidden] { display: none; }
.card__frontispiece { width: min(16rem, 70%); height: auto; color: var(--ink-2); display: block; margin: 0 auto; }
.card__number {
  margin: .35rem 0 0;
  font-size: .8rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--red);
}

.card__body { padding: 1.25rem .25rem .5rem; min-height: 11rem; }

/* The wish area has a fixed height per breakpoint: long texts shrink in steps
   until they fit (see fitText() in app.js). No inner scroll: the finger scrolls the page. */
.card .card__body {
  height: var(--body-height, 17rem);
  min-height: 0;
  margin-top: .75rem;
  padding: .25rem .5rem;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: safe center;
  outline: none;
}
.card .card__body:focus-visible { outline: 2px solid var(--focus-paper); outline-offset: 2px; }
@media (min-width: 640px) { .card { --body-height: 15rem; } }
/* on a phone, the card takes its height from its content: no empty band above the buttons */
@media (max-width: 639.98px) {
  .card .card__body { height: auto; min-height: 9rem; overflow: visible; }
}

.card--shake { animation: shake .55s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translate(-1px, 0) rotate(-.2deg); }
  20%, 80% { transform: translate(2px, 1px) rotate(.3deg); }
  30%, 50%, 70% { transform: translate(-3px, -1px) rotate(-.5deg); }
  40%, 60% { transform: translate(3px, 1px) rotate(.4deg); }
}

/* Empty state */
.empty { text-align: center; padding: 2rem 0 1rem; color: var(--ink-2); }
.empty__text { font-family: var(--f-hand); font-size: 1.35rem; margin: 0; }
.empty__sub { margin: .25rem 0 0; font-style: italic; opacity: .8; }

/* The wish */
.wish { margin: 0; min-width: 0; }

.wish__text {
  position: relative;
  margin: 0 0 1.25rem;
  font-family: var(--f-hand);
  font-size: clamp(1.7rem, 6.4vw, 2.6rem);
  line-height: 1.25;
  color: var(--ink);
  filter: url(#ink);
  text-wrap: balance;
  overflow-wrap: anywhere;
  overflow-x: clip;
}
.wish__text .visually-hidden { left: 0; top: 0; }
.wish__text--t2 { font-size: clamp(1.45rem, 5.4vw, 2.15rem); }
.wish__text--t3 { font-size: clamp(1.25rem, 4.6vw, 1.75rem); line-height: 1.3; margin-bottom: 1rem; }
.wish__text--t4 { font-size: clamp(1.1rem, 4vw, 1.45rem); line-height: 1.32; margin-bottom: .9rem; }
.wish__text--t5 { font-size: clamp(1rem, 3.6vw, 1.2rem); line-height: 1.35; margin-bottom: .8rem; }
.wish__text--t6 { font-size: clamp(.92rem, 3.3vw, 1.05rem); line-height: 1.35; margin-bottom: .6rem; }
.wish__text--t7 { font-size: clamp(.85rem, 3vw, .95rem); line-height: 1.35; margin-bottom: .5rem; }
.wish__text--t4 .drop-cap, .wish__text--t5 .drop-cap, .wish__text--t6 .drop-cap, .wish__text--t7 .drop-cap { font-size: 1.9em; }
.wish--squeezed .wish__explanation { -webkit-line-clamp: 2; line-clamp: 2; }
.wish--squeezed .rubric { margin-bottom: .4rem; }
.wish--static .letter { opacity: 1; animation: none; }
.wish--static .wish__details { opacity: 1; animation: none; }
.wish__text .drop-cap {
  float: left;
  font-family: var(--f-hand);
  font-weight: 400;
  font-size: 2.35em;
  line-height: .85;
  color: var(--red);
  margin: .06em .05em 0 0;
  text-shadow: 1px 1px 0 #7c1a1255;
}

.letter {
  display: inline;
  opacity: 0;
  animation: write .32s ease-out forwards;
  animation-delay: calc(var(--i) * var(--step, 42ms));
}
@keyframes write {
  0%   { opacity: 0; filter: blur(3px); text-shadow: 0 0 6px #2b1a10aa; }
  60%  { opacity: 1; filter: blur(.4px); }
  100% { opacity: 1; filter: none; text-shadow: none; }
}

.quill { /* the tip of the quill that follows the writing */
  display: inline-block;
  width: .08em; height: .9em;
  margin-left: .04em;
  vertical-align: -.08em;
  background: var(--red);
  opacity: 0;
  animation: quill-blink .7s steps(1) 12, quill-fade .3s forwards; /* finite; app.js removes it from the DOM at the end */
  animation-delay: 0s, var(--done, 1s);
}
@keyframes quill-blink { 0% { opacity: .9; } 50% { opacity: 0; } }
@keyframes quill-fade { to { opacity: 0; visibility: hidden; } }

.wish__details {
  opacity: 0;
  animation: rise-in .7s ease-out forwards;
  animation-delay: var(--done, .2s);
}

.rubric {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem;
  margin: 0 0 .8rem;
  font-size: .85rem;
}
.badge {
  display: inline-block;
  padding: .1rem .55rem .15rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-size: .75rem;
  font-weight: 700;
  color: var(--red);
}
.badge--level { color: var(--ink-2); }
.badge--generated {
  color: var(--paper);
  background: var(--red);
  border-color: var(--red);
  transform: rotate(-2deg);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--red);
}

.wish__explanation {
  margin: 0 0 .6rem; font-size: 1.02rem;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.wish__en { margin: 0 0 .9rem; font-size: .92rem; font-style: italic; color: var(--ink-2); }
.wish__en > span { font-style: normal; font-size: .7rem; letter-spacing: .12em; margin-right: .35rem; opacity: .8; }
/* the translation is always shown in full; if it does not fit, the card shrinks the text */
/* in English, the translation is the first thing to read after the wish */
.wish__en--large {
  margin: 0 0 .8rem;
  font-size: 1.12rem;
  color: var(--ink);
  padding-left: .7rem;
  border-left: 3px solid var(--red);
}
.in-romanian {
  display: inline-block;
  margin-right: .4rem;
  padding: 0 .35rem;
  font-size: .68rem;
  font-style: normal;
  letter-spacing: .08em;
  text-transform: uppercase;
  vertical-align: .1em;
  color: var(--ink-2);
  border: 1px dotted var(--ink-2);
  border-radius: 2px;
}
.in-romanian::before { content: "("; }
.in-romanian::after { content: ")"; }
.badge--vulgar { color: var(--red-dark); background: #a3271c14; }

.wish__source {
  margin: 0;
  padding-top: .6rem;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
  border-top: 1px solid #7a5a3355;
  font-size: .9rem;
  color: var(--ink-2);
}
.wish__source a { color: var(--red-dark); text-underline-offset: 3px; font-weight: 500; }
.wish__source a:hover { color: var(--red); }

/* Error */
.error { text-align: center; padding: 1.5rem 0 .5rem; }
.error__sign { font-size: 2.4rem; color: var(--red); margin: 0; line-height: 1; }
.error__title { font-family: var(--f-hand); font-size: 1.45rem; margin: .5rem 0 .25rem; }
.error__text { margin: 0; color: var(--ink-2); font-style: italic; }

/* Actions */
.card__actions {
  display: flex; flex-wrap: nowrap; gap: .4rem;
  justify-content: center;
  margin-top: .5rem;
  padding-top: .5rem;
}
/* three small "ghost" pills, always on one row; on a phone the icons disappear */
.card__actions .action {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  flex: 0 1 auto; min-width: 0;
  font-size: .9rem; min-height: 2.4rem; padding: .25rem .8rem;
  border-width: 1px; white-space: nowrap;
}
.action__icon { flex: none; }
@media (max-width: 419.98px) {
  .card__actions { gap: .3rem; margin-bottom: 2.1rem; }
  .card__actions .action { font-size: .85rem; padding: .25rem .7rem; gap: .25rem; }
  .card__actions .action__icon { display: none; }
}
@media (max-width: 359.98px) {
  .card__actions .action { font-size: .78rem; padding: .25rem .5rem; }
  .card__actions .action__icon { display: none; }
}
.card__actions[hidden] { display: none; }
.card__actions[data-empty] { visibility: hidden; }

.action {
  font: 500 1rem var(--f-text);
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink-2);
  border-radius: 999px;
  padding: .5rem 1rem;
  min-height: 2.75rem;
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
.action:hover { background: #2b1a1012; }
.action:active { transform: translateY(1px); }
.action:disabled { opacity: .45; cursor: default; transform: none; }
.action--small { font-size: .9rem; min-height: 2.4rem; padding: .3rem .8rem; }
.action--open { color: var(--paper); border-color: #c9a24d88; }
.action--open:hover:not(:disabled) { background: #c9a24d1f; }
.action--filled { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.action--filled:hover { background: var(--red-dark); border-color: var(--red-dark); }
.card .action:focus-visible { outline-color: var(--focus-paper); }

/* The "Share" menu (fallback when navigator.share is missing) */
.dialog--share { width: min(22rem, calc(100vw - 2rem)); padding: 1.6rem 1.2rem 1.2rem; contain: layout paint; }
.dialog--share h2 { font-size: 1.4rem; margin: 0 0 1rem; }
.share__list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.share__list .action { display: block; width: 100%; text-align: center; text-decoration: none; line-height: 1.6; box-sizing: border-box; }
.share__list a.action { color: var(--ink); }

.card__toast {
  position: absolute; left: 50%; bottom: -1.2rem;
  transform: translate(-50%, 0);
  margin: 0;
  padding: .35rem .9rem;
  background: var(--ink); color: var(--paper);
  font-size: .9rem; border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  width: max-content; max-width: calc(100vw - 2rem);
  text-align: center; line-height: 1.3;
}
.card__toast.visible { opacity: 1; transform: translate(-50%, -.4rem); }

/* Incense: little puffs rising from the card */
.incense { position: absolute; inset: 0; pointer-events: none; overflow-x: clip; overflow-y: visible; z-index: 2; }
.puff {
  position: absolute;
  bottom: 30%;
  width: var(--m, 90px); height: var(--m, 90px);
  border-radius: 50%;
  background: radial-gradient(circle, #f6efe0cc 0%, #d8cbb088 35%, transparent 70%);
  filter: blur(6px);
  opacity: 0;
  animation: puff var(--d, 2.4s) ease-out forwards;
  animation-delay: var(--w, 0s);
}
@keyframes puff {
  0%   { opacity: 0; transform: translate(0, 20px) scale(.4); }
  20%  { opacity: .85; }
  100% { opacity: 0; transform: translate(var(--dx, 0px), -180px) scale(1.8) rotate(40deg); }
}

/* ---------- For developers ---------- */

.developers {
  max-width: 52rem;
  margin: 1rem auto 0;
  padding: 2.5rem 1.25rem 3rem;
  border-top: 1px solid #c9a24d44;
}

.label {
  margin: 0;
  font-size: .8rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--red);
  filter: brightness(1.6);
}

.developers h2 {
  margin: 0 0 .6rem;
  font-family: var(--f-text);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 2.8rem);
  line-height: 1;
  color: var(--paper);
}
.developers__head p:last-child { margin: 0 0 1.5rem; color: #e9d9b4; max-width: 38rem; }
.developers__head code { color: var(--paper); }

.examples { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; counter-reset: ex; }
.example { counter-increment: ex; min-width: 0; }
.example__title { margin: 0 0 .35rem; color: var(--gold-pale); font-style: italic; }
.example__title::before {
  content: counter(ex, upper-roman) ". ";
  font-style: normal; font-weight: 700; color: var(--gold);
}
.example__code {
  position: relative;
  display: flex; align-items: stretch;
  background: #120c08;
  border: 1px solid #c9a24d33;
  border-radius: var(--radius);
}
.example__code pre {
  flex: 1; min-width: 0; margin: 0; padding: .85rem 1rem;
  overflow-x: auto;
  color: #f1e3c2;
  font-size: .9rem;
  line-height: 1.5;
}
.example__code pre::before { content: "$ "; color: var(--gold); }
.copy-code {
  flex: none;
  font: 500 .85rem var(--f-text);
  color: var(--gold-pale);
  background: #c9a24d14;
  border: 0;
  border-left: 1px solid #c9a24d33;
  padding: 0 1rem;
  min-width: 5.5rem;
  cursor: pointer;
}
.copy-code:hover { background: #c9a24d2a; }
.example__code { flex-wrap: wrap; }
.example__code .example__result::before { content: none; }
.example__code .example__result {
  flex: 1 0 100%; margin: 0; padding: .85rem 1rem; max-height: 18rem; overflow: auto;
  border-top: 1px solid #c9a24d33; color: #f1e3c2; font-size: .85rem; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.example__code .example__result[hidden] { display: none; }
/* On a phone the command takes the whole row and the buttons move below it. */
@media (max-width: 639px) {
  .example__code > pre:first-child { flex-basis: 100%; }
  .example__code .copy-code { flex: 1 1 0; padding: .7rem 1rem; border-left: 0; border-top: 1px solid #c9a24d33; }
  .example__code .copy-code + .copy-code { border-left: 1px solid #c9a24d33; }
}
.example__code .example__result--error { font-family: var(--f-text); font-style: italic; font-size: .95rem; color: var(--gold-pale); }

.big-links { display: grid; gap: .9rem; margin-top: 2rem; }
@media (min-width: 720px) {
  .big-links { grid-template-columns: 1.3fr 1fr; }
}
.big-link {
  display: flex; flex-direction: column; justify-content: center;
  padding: 1.2rem 1.25rem;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 10px 20px -12px #000;
  transition: transform .15s, box-shadow .15s;
}
.big-link:hover { transform: translateY(-3px) rotate(-.4deg); box-shadow: 0 16px 26px -14px #000; }
.big-link__label { font-family: var(--f-text); font-weight: 700; font-size: 1.6rem; line-height: 1.05; }
.big-link__label::after { content: " →"; font-family: var(--f-text); color: var(--red); }
.big-link__sub { font-family: var(--f-code); font-size: .82rem; margin-top: .35rem; color: var(--ink-2); }
.big-link--secondary { background: transparent; color: var(--paper); border: 1px solid #c9a24d66; box-shadow: none; }
.big-link--secondary .big-link__label { font-size: 1.3rem; }
.big-link--secondary .big-link__sub { color: #d8c391; font-family: var(--f-text); font-style: italic; font-size: .9rem; }
.big-link--secondary:hover { background: #c9a24d14; }
.big-link--github .big-link__label { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--f-text); font-weight: 700; }
.octicon { flex: none; width: 1.5rem; height: 1.5rem; }

/* Link to all the entries */
.browse { margin: 1.75rem 0 0; text-align: center; }

/* ---------- Browse by theme ---------- */
.themes { max-width: 46rem; margin: 0 auto; padding: 0 1.25rem 3rem; text-align: center; }
.themes[hidden] { display: none; }
.themes__sub { margin: -.5rem 0 1.1rem; font-size: .95rem; font-style: italic; color: #d8c391; }
.themes h2 {
  margin: 0 0 1rem;
  font-family: var(--f-text); font-weight: 700;
  font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1.1;
  color: var(--paper);
}
.themes__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: .55rem; }
.theme-chip {
  display: inline-flex; align-items: baseline; gap: .5rem;
  min-height: 2.5rem; align-items: center;
  padding: .3rem .95rem;
  font: 500 1rem var(--f-text); text-decoration: none;
  color: var(--gold-pale);
  border: 1.5px solid var(--gold); border-radius: 999px;
  transition: background .2s, color .2s;
}
.theme-chip:hover { background: #c9a24d26; color: var(--paper); }
.theme-chip__n { font-size: .8rem; opacity: .75; font-variant-numeric: tabular-nums; }
.browse a {
  display: inline-block;
  font-family: var(--f-hand);
  font-size: 1.2rem;
  color: var(--paper);
  text-decoration: none;
  padding: .4rem .2rem;
  border-bottom: 1px solid #c9a24d88;
  transition: color .2s, border-color .2s;
}
.browse a:hover { color: var(--gold-pale); border-bottom-color: var(--gold); }
.browse a span[aria-hidden] { color: var(--gold); }

/* ---------- Footer ---------- */

.footer {
  text-align: center;
  padding: 2rem 1.25rem 3rem;
  color: #d8c391;
  font-size: .95rem;
}
.footer__colophon { font-family: var(--f-title); font-size: 1.4rem; color: var(--gold); margin: 0 0 1rem; }
.footer__licenses {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem 1.4rem;
}
.footer__licenses li + li::before { content: "·"; margin-right: 1.4rem; margin-left: -1.4rem; color: var(--gold); position: relative; left: .7rem; }
.footer__licenses a { color: var(--paper); text-underline-offset: 3px; }
.footer__note { margin: 1rem auto 0; max-width: 32rem; font-style: italic; opacity: .85; font-size: .88rem; }

/* ---------- Dialog ---------- */

.dialog {
  max-width: min(26rem, calc(100vw - 2rem));
  padding: 2rem 1.5rem 1.5rem;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 0 0 1px var(--paper-shadow), 0 0 0 6px var(--paper), 0 0 0 7px var(--ink-2), 0 30px 80px #000;
  text-align: center;
}
.dialog::backdrop { background: #120c08eb; }
.dialog:focus, .dialog :focus:not(:focus-visible) { outline: none; }
.dialog[open] { animation: dialog-in .22s ease-out; }
.dialog[open]::backdrop { animation: backdrop-in .22s ease-out; }
.dialog.closing { animation: dialog-out .2s ease-in forwards; }
.dialog.closing::backdrop { animation: backdrop-out .2s ease-in forwards; }
@keyframes dialog-in { from { opacity: 0; transform: scale(.94); } }
@keyframes dialog-out { to { opacity: 0; transform: scale(.94); } }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes backdrop-out { to { opacity: 0; } }
.dialog h2 { font-family: var(--f-text); font-weight: 700; font-size: 1.8rem; line-height: 1.05; margin: .5rem 0 .75rem; }
.dialog p { margin: 0 0 1.25rem; }

/* ---------- Language switch ---------- */

.language {
  position: absolute; top: .9rem; right: 1rem; z-index: 5;
  display: flex;
  border: 1px solid #c9a24d66;
  border-radius: 999px;
  overflow: hidden;
  background: #00000033;
}
.language button {
  font: 700 .78rem var(--f-text);
  letter-spacing: .12em;
  color: var(--gold-pale);
  background: none;
  border: 0;
  padding: .45rem .75rem;
  min-width: 2.75rem; min-height: 2.25rem;
  cursor: pointer;
}
.language button + button { border-left: 1px solid #c9a24d44; }
.language button:hover { background: #c9a24d1f; }
.language button[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
.language button:focus-visible { outline-offset: -3px; }
.header { padding-top: 4.5rem; }
@media (min-width: 640px) { .header { padding-top: 2.5rem; } }

/* ---------- The "Meaning and source" dialog ---------- */

.sheet {
  width: min(36rem, calc(100vw - 1.5rem));
  max-width: none;
  max-height: min(42rem, calc(100dvh - 2rem));
  padding: 2rem 1.4rem 1.5rem;
  text-align: left;
  overflow-y: auto;
  overscroll-behavior: contain;
  contain: layout paint;
  /* the bar keeps its space reserved, so the text does not move when it appears or disappears */
  scrollbar-gutter: stable both-edges;
}
@media (min-width: 640px) { .sheet { padding: 2.4rem 2.2rem 2rem; } }
.sheet__body { transition: opacity .15s; }
.sheet__body--waiting { opacity: .45; pointer-events: none; transition-delay: .12s; }
.sheet__close {
  position: sticky; top: -1.2rem; float: right;
  margin: -1.2rem -.6rem 0 .5rem;
  width: 2.75rem; height: 2.75rem;
  font: 400 1.9rem/1 var(--f-text);
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid #7a5a3355;
  border-radius: 50%;
  cursor: pointer;
  z-index: 1;
}
.sheet__close:hover { color: var(--red); border-color: var(--red); }
.sheet .sheet__body p { margin: 0 0 .9rem; }
.sheet .sheet__body .sheet__label {
  font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; color: var(--red);
  margin-bottom: .3rem;
}
.sheet h2.sheet__title {
  font-family: var(--f-hand); font-weight: 400;
  font-size: clamp(1.5rem, 5.5vw, 2rem); line-height: 1.2;
  margin: 0 0 .6rem;
  outline: none;
  text-wrap: balance;
}
.sheet__title--waiting { color: var(--ink-2); font-style: italic; }
.sheet__original { font-style: italic; color: var(--ink-2); }
.sheet__original > span:first-child { font-style: normal; font-size: .85rem; }
.sheet__explanation { font-size: 1.05rem; }
.sheet .wish__en--large { margin: 0 0 .9rem; }
.sheet__data {
  display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem;
  margin: 0 0 1rem; padding: .75rem 0;
  border-top: 1px solid #7a5a3355; border-bottom: 1px solid #7a5a3355;
  font-size: .95rem;
}
.sheet__data dt { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); padding-top: .15rem; }
.sheet__data dd { margin: 0; }
.sheet__subtitle { font-family: var(--f-text); font-weight: 700; font-size: 1.35rem; margin: 0 0 .5rem; color: var(--red-dark); }
.sheet__sources { margin: 0; padding-left: 1.4rem; display: grid; gap: .65rem; }
.sheet__sources li::marker { color: var(--red); font-weight: 700; }
.sheet__source { display: flex; flex-direction: column; gap: .1rem; }
.sheet__source cite { font-style: italic; overflow-wrap: anywhere; }
.sheet__source-meta { font-size: .88rem; color: var(--ink-2); }
.sheet__source a { align-self: flex-start; font-size: .92rem; font-weight: 500; color: var(--red-dark); text-underline-offset: 3px; padding: .2rem 0; }
.sheet__source a:hover { color: var(--red); }
.sheet__note { font-style: italic; color: var(--ink-2); }
.sheet__parts { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.sheet__part {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .1rem .8rem;
  padding: .6rem .8rem; border: 1px dashed #7a5a3388; border-radius: var(--radius);
}
.sheet__part-label { grid-column: 1; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.sheet__part-text { grid-column: 1; font-family: var(--f-hand); font-size: 1.25rem; }
.sheet__part .action { grid-column: 2; grid-row: 1 / span 2; }
.sheet__actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 .9rem; }
.sheet__back {
  font: italic .95rem var(--f-text); color: var(--red-dark);
  background: none; border: 0; padding: .3rem 0; margin: 0 0 .6rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- The all-entries page ---------- */

.header--small { padding-bottom: 1rem; }
.header--small .header__title { font-size: clamp(2.4rem, 10vw, 4rem); }
.header--small .header__eyebrow { font-family: var(--f-title); font-size: 1.2rem; letter-spacing: .04em; text-transform: none; margin-bottom: .4rem; }
.header__back { margin: 0 0 1.25rem; text-align: left; }
.header__back a { color: var(--gold-pale); text-underline-offset: 3px; font-style: italic; }
.header__back a:hover { color: var(--paper); }

.register { max-width: 52rem; margin: 0 auto; padding: .5rem 1rem 3rem; }

.search { display: grid; gap: 1rem; margin-bottom: 1.25rem; }
.search label {
  display: block;
  font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
  margin-bottom: .35rem;
}
.search input, .search select {
  width: 100%;
  font: inherit;
  color: var(--paper);
  background-color: #00000040;
  border: 1px solid #c9a24d66;
  border-radius: var(--radius);
  min-height: 2.9rem;
  padding: .55rem .8rem;
}
.search input { font-size: 1.15rem; font-family: var(--f-hand); }
.search input::placeholder { color: #d8c39188; }
.search input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none;
  width: 1.3rem; height: 1.3rem; margin-left: .4rem; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Cpath d='M2 2l10 10M12 2L2 12' fill='none' stroke='%23c9a24d' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.search input[type="search"]::-webkit-search-cancel-button:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Cpath d='M2 2l10 10M12 2L2 12' fill='none' stroke='%23f1e3c2' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
.search input:focus-visible, .search select:focus-visible, .theme select:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; border-color: var(--focus);
}
.search select {
  appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23c9a24d' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center;
}
.search select option { color: var(--ink); background: var(--paper); }
.search small { display: block; margin-top: .3rem; font-style: italic; color: #d8c391; font-size: .85rem; }
.search__filters { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (min-width: 720px) { .search__filters { grid-template-columns: repeat(4, 1fr); } }
.filter { min-width: 0; }
.search__mobile, .chips { display: none; }
@media (max-width: 639.98px) {
  .search { gap: .75rem; }
  .search__mobile { display: block; }
  .search__mobile .action { width: 100%; border-radius: var(--radius); text-align: left; display: flex; justify-content: space-between; align-items: center; }
  .search__mobile .action::after { content: "▾"; margin-left: .6rem; transition: transform .2s; }
  .search__mobile .action[aria-expanded="true"]::after { transform: rotate(180deg); }
  .search__filters { display: none; }
  .search[data-open] .search__filters { display: grid; }
  .chips { display: flex; flex-wrap: wrap; gap: .4rem; }
  .search[data-open] .chips { display: none; }
  .chip {
    display: inline-flex; align-items: center; gap: .45rem;
    font: 500 .92rem var(--f-text); color: var(--ink);
    background: var(--gold-pale); border: 0; border-radius: 999px;
    padding: .3rem .55rem .3rem .8rem; min-height: 2.2rem; cursor: pointer;
  }
  .chip span { font-size: 1.1rem; line-height: 1; }
}
.search__status { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem; margin: 0; min-height: 1.6rem; }
.search__status output { font-family: var(--f-hand); font-size: 1.15rem; color: var(--paper); }
.text-button {
  font: italic .95rem var(--f-text); color: var(--gold-pale);
  background: none; border: 0; padding: .3rem 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.text-button:hover { color: var(--paper); }
.text-button[hidden] { display: none; }

.register__leaf {
  position: relative;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 15% 0%, #ffffff55, transparent 40%),
    radial-gradient(ellipse at center, transparent 70%, #a57c3a44 100%);
  border-radius: 3px 6px 4px 3px;
  box-shadow: var(--card-shadow);
  padding: .75rem .5rem;
  outline: none;
  scroll-margin-top: 1rem;
  transition: opacity .2s;
}
@media (min-width: 640px) { .register__leaf { padding: 1.25rem 1.5rem; } }
.register__leaf.loading { opacity: .6; }
.register__leaf::before {
  content: ""; position: absolute; inset: .4rem;
  border: 1px solid #7a5a3344; border-radius: 2px; pointer-events: none;
}

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px dotted #7a5a3377; }
.entry {
  position: relative;
  display: grid; gap: .2rem;
  width: 100%;
  text-align: left;
  font: inherit; color: inherit;
  background: none; border: 0;
  padding: .75rem .6rem;
  cursor: pointer;
  border-radius: 2px;
  -webkit-user-select: text; user-select: text;
}
.entry:hover { background: #a3271c0d; }
.entry:hover .entry__text { color: var(--red-dark); }
.register .entry:focus-visible { outline-color: var(--focus-paper); outline-offset: -2px; }
.entry__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .2rem .75rem; }
.entry__text { font-family: var(--f-hand); font-size: 1.2rem; line-height: 1.25; transition: color .15s; }
.entry__badges { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.entry__badges .badge { font-size: .62rem; padding: 0 .4rem .05rem; }
.entry__en { font-style: italic; color: var(--ink); font-size: 1rem; }
.entry__explanation { font-size: .92rem; color: var(--ink-2); line-height: 1.4; }
.list__empty { text-align: center; padding: 2.5rem 1rem; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1.25rem; }
.pagination[hidden] { display: none; }
.pagination__where { font-style: italic; color: #d8c391; text-align: center; }
.pagination .action { padding: .5rem .8rem; }
@media (max-width: 420px) { .pagination .action { font-size: .9rem; } }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .card--shake, .puff { animation: none !important; }
  html.i18n-pending body { animation-duration: 0s !important; animation-delay: 2s !important; }
  .letter { opacity: 1; animation: none !important; }
  .quill { display: none; }
  .wish--fade, .wish__details { animation: fade .4s ease-out forwards !important; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
}

@media (forced-colors: active) {
  .level__option input:checked + span { outline: 2px solid CanvasText; }
  .wish__text { filter: none; }
}

/* ---------- 404 page ---------- */

.page-404 .card { min-height: 0; padding-bottom: 2rem; }
.actions-404 { display: flex; flex-direction: column; align-items: center; gap: .9rem; margin-top: 1.75rem; }
.actions-404 .main-button, .actions-404 .secondary-button { text-decoration: none; }
.actions-404 .secondary-button { color: var(--red-dark); border: 1.5px solid #7a5a3388; font-style: normal; padding: .35rem 1.3rem; }
.actions-404 .secondary-button:hover { color: var(--red); text-decoration-color: transparent; background: #a3271c10; }

/* On wide screens the card content is centered, like its title and buttons;
   the initial becomes a large inline letter, not a floating one that would run over the next line. */
.wish__text { display: flow-root; }
/* on small screens the "ink" filter roughens the letters: we turn it off */
@media (max-width: 639.98px) { .wish__text { filter: none; } }
@media (min-width: 640px) {
  .card .wish { text-align: center; max-width: 36rem; margin-inline: auto; }
  .card .wish__text .drop-cap,
  .card .wish__text--t4 .drop-cap,
  .card .wish__text--t5 .drop-cap {
    float: none; display: inline; font-size: 1.45em; line-height: 0; margin: 0 .04em 0 0; vertical-align: -.06em;
  }
  .card .rubric { justify-content: center; }
  .card .wish__en--large { border-left: 0; padding-left: 0; }
}

.header__small { text-wrap: balance; }

/* Scrollbars in tune with the rest: thin, gold on the dark background, brown on paper. */
html { scrollbar-color: #c9a24d73 #120c08; }
.dialog, .example__result, .example__code pre { scrollbar-width: thin; }
.dialog { scrollbar-color: #7a5a3380 transparent; }
.example__result, .example__code pre { scrollbar-color: #c9a24d59 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9a24d73; border: 3px solid transparent; border-radius: 10px; background-clip: padding-box; }
.dialog::-webkit-scrollbar-thumb { background-color: #7a5a3380; }
