/* Secret Santa: a Swedish julklapp in kraft paper, a gift tag and a red wax seal.
   Spruce (granris) page, lingonberry wax, kraft tag, snow sheet, straw star. */

@font-face {
  font-family: "Young Serif";
  src: url("/static/fonts/young-serif-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/static/fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --spruce: #123d2f;
  --spruce-deep: #0d2e23;
  --lingonberry: #b01e2d;
  --lingonberry-deep: #8c1522;
  --kraft: #c8a074;
  --snow: #f2f5f2;
  --ink: #1e3229;
  --straw: #e8be5a;
  --snow-muted: #b9ccc2; /* secondary text on spruce, 7.2:1 */
  --ink-muted: #4a5e55; /* secondary text on snow, 6.3:1 */
  --rule: #b8c6be;

  --serif: "Young Serif", Georgia, "Times New Roman", serif;
  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Type scale (16 px root): 14, 18, 21, 24, 36, 48 */
  --step--1: 0.875rem;
  --step-0: 1.125rem;
  --step-1: 1.3125rem;
  --step-2: 1.5rem;
  --step-3: 2.25rem;
  --step-4: 3rem;

  --focus: var(--straw);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--spruce);
  color: var(--snow);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Components set their own display, which would otherwise beat [hidden]. */
[hidden] {
  display: none !important;
}

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

/* --- The short message pages: "/" and "Länken är ogiltig" --- */

.page-message {
  display: grid;
  place-items: center;
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.message {
  max-width: 21rem;
}

.message__star {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1.75rem;
}

.message__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--step-2);
  line-height: 1.25;
  text-wrap: balance;
}

.message__text {
  margin: 1rem 0 0;
  color: var(--snow-muted);
  text-wrap: pretty;
}

/* --- The host page: a spruce band, then one snow sheet --- */

.page-host {
  display: flex;
  flex-direction: column;
}

.band {
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1;
}

.wordmark__star {
  width: 1.75rem;
  height: 1.75rem;
}

.band__title {
  margin: 2rem 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--step-3);
  line-height: 1.1;
}

.band__text {
  max-width: 30rem;
  margin: 0.75rem 0 0;
  color: var(--snow-muted);
}

.sheet {
  --focus: var(--spruce);
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  background: var(--snow);
  color: var(--ink);
  border-radius: 0.375rem 0.375rem 0 0;
  width: 100%;
  /* On a phone the sheet runs to the bottom of the screen. */
  flex: 1 0 auto;
}

.section + .section {
  margin-top: 2.5rem;
}

.section__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--step-2);
  line-height: 1.2;
}

.status {
  margin: 1.5rem 0 0;
  color: var(--ink-muted);
}

.section__text {
  margin: 0.5rem 0 1rem;
}

.locked {
  margin: 1rem 0 0;
}

/* --- Form controls (on the snow sheet) --- */

.label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: var(--step--1);
  font-weight: 600;
}

.field {
  min-width: 0;
  min-height: 3rem;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid #6f8279; /* 3.7:1 against the sheet */
  border-radius: 0.375rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.field[aria-invalid="true"] {
  border-color: var(--lingonberry);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.5rem 1.125rem;
  border: 1.5px solid transparent;
  border-radius: 0.375rem;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

.button:disabled {
  cursor: default;
  opacity: 0.6;
}

.button--primary {
  background: var(--lingonberry);
  color: var(--snow);
}

.button--primary:hover:not(:disabled) {
  background: var(--lingonberry-deep);
}

.button--primary:disabled {
  background: #cdd6d1;
  color: var(--ink-muted);
  opacity: 1;
}

.button--secondary {
  border-color: var(--spruce);
  color: var(--spruce);
}

.button--secondary:hover {
  background: rgba(18, 61, 47, 0.08);
}

.button--quiet {
  min-height: 2.75rem;
  padding-inline: 0.5rem;
  margin-right: -0.5rem;
  color: var(--lingonberry);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.button--quiet:hover {
  text-decoration-thickness: 2px;
}

.form-error {
  margin: 0.5rem 0 0;
  color: var(--lingonberry);
  font-weight: 500;
}

.form-message {
  margin: 0.5rem 0 0;
  font-weight: 500;
}

.form-message:empty {
  display: none;
}

.form-message--error {
  color: var(--lingonberry);
}

.hint {
  margin: 0.5rem 0 0;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* A field with its unit ("kr") inside, at the right. */
.unit-field {
  position: relative;
  flex: 1;
  min-width: 0; /* lets the row shrink on small phones */
  display: flex;
}

.unit-field .field {
  flex: 1;
  width: 100%;
  padding-right: 2.75rem;
}

.unit-field__unit {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

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

/* --- Adding and listing Participants --- */

.inline-form {
  margin-top: 1.25rem;
}

.inline-form__row {
  display: flex;
  gap: 0.5rem;
}

.inline-form__row > .field {
  flex: 1;
}

.people {
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--rule);
}

.person {
  padding: 1rem 0 1.125rem;
  border-top: 1px solid var(--rule);
}

.person__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.person__name {
  margin: 0;
  font-family: var(--serif);
  font-size: var(--step-1);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.person__link-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.field--link {
  flex: 1;
  color: var(--ink-muted);
  font-size: 1rem; /* under 16 px, iOS Safari zooms in when the field gets focus */
  text-overflow: ellipsis;
}

.reset {
  margin-top: 3rem;
}

.reset .button--quiet {
  margin: 0 0 0 -0.5rem;
}

.reset .hint {
  margin-top: 0.25rem;
}

.person__seen {
  margin: 0;
  flex-shrink: 0;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.person__seen--yes {
  color: var(--spruce);
  font-weight: 600;
}

.person__seen--yes::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: var(--spruce);
  vertical-align: 0.1em;
}

.person__hint {
  margin: 0.5rem 0 0;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* --- The Personal Link page: a kraft gift tag hanging on red-and-white twine --- */

.page-personal {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.25rem 3rem;
}

.topbar {
  width: 100%;
  max-width: 40rem;
}

.hang {
  position: relative;
  width: 100%;
  max-width: 20rem;
  margin-top: 5.5rem;
}

/* The shadow sits on its own wrapper because the tag's clip-path would cut it off. */
.tag-shadow {
  filter: drop-shadow(0 0.75rem 1rem rgba(3, 18, 12, 0.4));
}

/* The twine runs down from the top edge of the page and ends in the tag's hole. */
.hang::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% - 2rem);
  z-index: 1;
  width: 3px;
  height: 12rem;
  margin-left: -1.5px;
  border-radius: 2px;
  background: repeating-linear-gradient(to bottom, var(--lingonberry) 0 0.4rem, var(--snow) 0.4rem 0.7rem);
}

.tag {
  --focus: var(--spruce);
  position: relative;
  padding: 4rem 1.5rem 2.25rem;
  background: var(--kraft);
  color: var(--ink);
  text-align: center;
  clip-path: polygon(3.25rem 0, calc(100% - 3.25rem) 0, 100% 3.25rem, 100% 100%, 0 100%, 0 3.25rem);
}

/* The punched hole with its reinforcement ring. */
.tag::before {
  content: "";
  position: absolute;
  top: 1.45rem;
  left: 50%;
  width: 1.1rem;
  height: 1.1rem;
  margin-left: -0.55rem;
  border-radius: 50%;
  background: var(--spruce);
  box-shadow: 0 0 0 0.35rem #b08658;
}

.tag__greeting {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--step-3);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

/* personal.js picks the largest size at which no word has to break. */
.tag__greeting--long {
  font-size: var(--step-2);
  line-height: 1.2;
}

.tag__greeting--longer {
  font-size: var(--step-1);
  line-height: 1.2;
}

.tag__budget {
  margin: 0.625rem 0 0;
  font-weight: 600;
}

.tag__greeting:empty {
  display: none;
}

.tag__text {
  margin: 1rem 0 0;
  text-wrap: pretty;
}

.tag__greeting:empty ~ .tag__text {
  margin-top: 0;
}

/* The wax seal is the reveal button. Breaking it is the page's one animation. */

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.tag__seal {
  margin-top: 1.5rem;
}

.seal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 0.5rem 0.875rem;
  border: 0;
  border-radius: 0.5rem;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.seal:disabled {
  cursor: progress;
}

.seal__wax {
  position: relative;
  display: block;
  width: 7.5rem;
  height: 7.5rem;
  filter: drop-shadow(0 0.2rem 0.15rem rgba(70, 8, 16, 0.45));
  transition: transform 0.2s ease-out;
}

.seal:hover:not(:disabled) .seal__wax {
  transform: rotate(-6deg) scale(1.03);
}

.seal:active:not(:disabled) .seal__wax {
  transform: scale(0.97);
}

.seal__half {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition:
    transform 0.6s cubic-bezier(0.3, 0.6, 0.35, 1),
    opacity 0.3s ease-in 0.3s;
}

/* The two halves meet along a jagged crack. */
.seal__half--left {
  clip-path: polygon(0 0, 53% 0, 47% 17%, 56% 33%, 44% 51%, 55% 67%, 46% 84%, 52% 100%, 0 100%);
}

.seal__half--right {
  clip-path: polygon(53% 0, 100% 0, 100% 100%, 52% 100%, 46% 84%, 55% 67%, 44% 51%, 56% 33%, 47% 17%);
}

.is-cracked .seal__half--left {
  transform: translate(-18%, 12%) rotate(-18deg);
  opacity: 0;
}

.is-cracked .seal__half--right {
  transform: translate(18%, 16%) rotate(14deg);
  opacity: 0;
}

.is-cracked .seal__label {
  opacity: 0;
  transition: opacity 0.2s;
}

.seal__label {
  max-width: 14rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-wrap: balance;
}

.tag__error {
  margin: 0.5rem 0 0;
  font-weight: 600;
}

.reveal {
  margin-top: 1.75rem;
  animation: reveal-in 0.5s ease-out both;
}

/* The result gets focus so screen readers read it; it isn't a control. */
.reveal:focus {
  outline: none;
}

.reveal__lead {
  margin: 0;
}

.reveal__name {
  margin: 0.25rem 0 0;
  font-family: var(--serif);
  font-size: var(--step-4);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.reveal__name--long {
  font-size: var(--step-3);
}

.reveal__name--longer {
  font-size: var(--step-2);
}

/* Set by personal.js while it measures a name with every word kept whole. */
.tag__greeting.is-measuring,
.reveal__name.is-measuring {
  overflow-wrap: normal;
}

@keyframes reveal-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

@media (min-width: 42rem) {
  .band {
    padding: 2.5rem 2rem;
  }

  .band__title {
    font-size: var(--step-4);
  }

  .sheet {
    padding: 2rem 2rem 3rem;
    border-radius: 0.375rem;
    margin-bottom: 3rem;
    flex: 0 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
