@import url("./assets/fonts/noto-sans-sc/index.css");

:root {
  --ink: #000000;
  --muted: #6b7280;
  --paper: #ffffff;
  --surface: #ffffff;
  --line: rgba(0, 0, 0, 0.08);
  --green: #b509ac;
  --green-deep: #8c0785;
  --red: #dc2626;
  /* System serifs only: the app self-hosts one sans family and the CSP blocks
     outside font hosts, so the gift pages borrow the reader's own serif. */
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC Variable", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  color: var(--ink);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.admin-link,
.text-button {
  border: 0;
  padding: 0;
  color: var(--green);
  background: transparent;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.admin-link:hover,
.admin-link:focus-visible,
.text-button:hover,
.text-button:focus-visible {
  color: var(--green-deep);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 56px;
}

.chronicle-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin: 20px 0 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.chronicle-heading h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.quiet-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.chronicle-heading .quiet-note {
  text-align: right;
}

.year-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 168px;
}

.year-control strong {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.icon-button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font-size: 1rem;
  transition: all 0.15s ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--green);
  color: var(--green);
  outline: 2px solid rgba(181, 9, 172, 0.15);
  outline-offset: 1px;
}

.year-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px 20px;
}

.month {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 14px 14px;
  box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.04);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.month:hover {
  box-shadow: 0 6px 18px 0 rgba(0, 0, 0, 0.07);
}

.month-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink);
}

.weekday-row,
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row span {
  padding-bottom: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  text-align: center;
}

.day,
.blank-day {
  aspect-ratio: 1;
  min-width: 0;
}

.day {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #1f2937;
  background: transparent;
  font-size: 0.78rem;
}

.day-number {
  position: relative;
  z-index: 1;
  line-height: 1;
}

.day.has-birthday {
  color: var(--green);
  background: transparent;
  font-weight: 650;
  cursor: pointer;
  transition:
    color 0.15s ease,
    background-color 0.15s ease,
    transform 0.1s ease;
}

.day.has-birthday:hover,
.day.has-birthday:focus-visible {
  color: var(--green-deep);
  background: rgba(181, 9, 172, 0.08);
  outline: 2px solid rgba(181, 9, 172, 0.28);
  outline-offset: 2px;
}

.day.has-birthday:active {
  transform: scale(0.96);
}

@keyframes birthdayRingRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.birthday-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--green);
  pointer-events: none;
  overflow: visible;
  transform-origin: center;
  animation: birthdayRingRotate 10s linear infinite;
  transition: color 0.15s ease;
}

.day.has-birthday:hover .birthday-ring,
.day.has-birthday:focus-visible .birthday-ring {
  color: var(--green-deep);
}

.personal-area {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.personal-heading,
.form-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.personal-heading h2 {
  margin: 0 0 20px;
  font-size: 1.65rem;
  font-weight: 550;
}

.campaign-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.campaign-card {
  display: flex;
  min-height: 200px;
  flex-direction: column;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.04);
}

.campaign-card h3 {
  margin: 4px 0 10px;
  font-size: 1.1rem;
  font-weight: 650;
}

.campaign-card p {
  margin: 0;
  color: #374151;
  white-space: pre-line;
}

.campaign-card .primary-button {
  margin-top: auto;
}

.kind-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.claim-form {
  max-width: 860px;
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.04);
}

.claim-form h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 650;
}

.address-history {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.address-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.address-option input {
  width: 16px;
  height: 16px;
}

.address-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 0 4px;
  border: 0;
  border-top: 1px solid var(--line);
}

.address-fields legend {
  padding: 0 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

input,
textarea,
select {
  min-width: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
  outline: 2px solid rgba(181, 9, 172, 0.18);
}

.wide {
  grid-column: 1 / -1;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  color: var(--ink);
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.primary-button {
  align-self: flex-start;
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 9px 16px;
  color: #fff;
  background: var(--green);
  font-weight: 600;
  transition: all 0.15s ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  border-color: var(--green-deep);
  background: var(--green-deep);
  outline: 2px solid rgba(181, 9, 172, 0.25);
  outline-offset: 1px;
}

.form-status {
  min-height: 1.5em;
  margin: 12px 0;
  color: var(--red);
  font-size: 0.9rem;
}

.form-status.success {
  color: var(--green);
}

.challenge-dialog {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.challenge-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.challenge-dialog form {
  position: relative;
  padding: 28px;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 1.4rem;
}

.dialog-close:hover,
.dialog-close:focus-visible {
  color: var(--ink);
}

.challenge-dialog h2 {
  margin: 0 0 14px;
  font-size: 1.35rem;
  font-weight: 550;
}

.challenge-prompt {
  margin: 0 0 10px;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.4;
}

.answer-label {
  margin-top: 18px;
}

/* Invite card page */
.invite-wrap {
  display: grid;
  min-height: calc(100vh - 72px);
  place-items: center;
  padding: 28px 0;
}

.invite-card {
  width: min(560px, 100%);
  padding: clamp(28px, 6vw, 56px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.04);
  text-align: center;
}

.invite-card--evergreen {
  border-color: var(--line);
  background: #ffffff;
}

.invite-card--cranberry {
  border-color: #fecdd3;
  background: #fff5f5;
}

.invite-card--midnight {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.invite-card .kind-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.invite-card h1 {
  margin: 8px 0 16px;
  font-size: clamp(1.85rem, 5vw, 2.75rem);
  font-weight: 550;
  line-height: 1.2;
}

.invite-card h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
  font-weight: 600;
}

.invite-card p {
  margin: 0;
  white-space: pre-line;
}

.invite-card .card-footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.invite-card .primary-button {
  margin-top: 24px;
}

.card-media-hint {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* The gift surfaces read as a letter: serif prose, roomy leading, and the
   controls and labels left in the interface sans. */
.invite-card h1,
.invite-card h2,
.invite-card p,
.claim-card h2,
.claim-card p,
.claim-form h3,
.claim-receipt h3,
.receipt-list dd,
.challenge-dialog h2,
.challenge-prompt,
.campaign-card h3,
.campaign-card p,
.media-item figcaption {
  font-family: var(--serif);
}

.invite-card p,
.claim-card p,
.campaign-card p {
  line-height: 1.85;
}

.invite-card h1 {
  font-weight: 500;
  letter-spacing: 0.01em;
}

.invite-card h2,
.claim-card h2 {
  font-weight: 550;
}

.claim-card p,
.invite-card p {
  font-size: 1.02rem;
}

.claim-form h3,
.claim-receipt h3 {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.receipt-list dd {
  font-size: 1rem;
}

/* Claim stage: the card, its gift media and the address form on one page */
.hidden {
  display: none !important;
}

.invite-wrap--stage {
  min-height: 0;
  place-items: start center;
}

.claim-stage {
  display: grid;
  width: min(720px, 100%);
  gap: 20px;
}

.claim-card {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.04);
}

.claim-card--evergreen {
  border-color: var(--line);
  background: #ffffff;
}
.claim-card--cranberry {
  border-color: #fecdd3;
  background: #fff5f5;
}
.claim-card--midnight {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.claim-card h2 {
  margin: 6px 0 10px;
  font-size: 1.25rem;
  font-weight: 600;
}

.claim-card p {
  margin: 0;
  white-space: pre-line;
}

.claim-card .card-footer {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* One centred column: every photo and clip keeps its own proportions and sits
   in the middle, like pictures tucked into a letter. */
.media-gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 18px;
}

.media-item {
  display: grid;
  justify-items: center;
  max-width: 100%;
  margin: 0;
  gap: 8px;
}

.media-open {
  overflow: hidden;
  /* Holds the frame open while a photo is still on its way. */
  min-width: 120px;
  min-height: 90px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  background: #f3f4f6;
  cursor: zoom-in;
  line-height: 0;
}

.media-item img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 46vh;
  object-fit: contain;
}

.media-item video {
  display: block;
  width: 100%;
  max-height: 56vh;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #000;
}

.media-item figcaption {
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.media-dialog {
  position: relative;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: transparent;
}

.media-dialog::backdrop {
  background: rgba(0, 0, 0, 0.85);
}

.media-dialog img {
  display: block;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  border-radius: 6px;
}

.media-dialog .dialog-close {
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  color: #fff;
  /* The photo underneath can be any colour, so the button carries its own. */
  background: rgba(0, 0, 0, 0.6);
  font-size: 1.5rem;
  line-height: 1;
}

.media-dialog .dialog-close:hover,
.media-dialog .dialog-close:focus-visible {
  color: #fff;
  background: rgba(0, 0, 0, 0.85);
}

.claim-stage .claim-form {
  max-width: none;
  margin-top: 0;
}

.paste-box textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  font-size: 0.95rem;
}

.claim-receipt {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.04);
}

.claim-receipt h3 {
  margin: 0 0 14px;
  font-size: 1.1rem;
  font-weight: 650;
}

.receipt-list {
  display: grid;
  margin: 0 0 16px;
  gap: 10px;
}

.receipt-list div {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 12px;
}

.receipt-list dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.receipt-list dd {
  margin: 0;
}

@media (max-width: 980px) {
  .year-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .site-header,
  main {
    padding-right: 16px;
    padding-left: 16px;
  }

  .chronicle-heading {
    grid-template-columns: 1fr auto;
    margin-top: 16px;
  }

  .chronicle-heading h1 {
    font-size: 2.1rem;
  }
  .chronicle-heading .quiet-note {
    display: none;
  }
  .year-control {
    grid-column: 2;
  }
  .year-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 14px;
  }
  .address-fields {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: auto;
  }
  .personal-heading h2 {
    font-size: 1.4rem;
  }
  .receipt-list div {
    grid-template-columns: 60px 1fr;
  }
}

@media (max-width: 380px) {
  .year-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
  .birthday-ring {
    animation: none !important;
  }
}
