@font-face {
  font-family: "Scheherazade New";
  src: url("assets/fonts/ScheherazadeNew-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --ivory: #f5efdf;
  --paper: #fffaf0;
  --olive: #263c31;
  --olive-soft: #52685a;
  --gold: #9b7a3d;
  --gold-pale: #d9c9a6;
  --rule: #ded2b8;
  --reserved: #f1e2bd;
  --completed: #e2eadf;
  --completed-ink: #2f5a3f;
  --alert: #8a3b22;
  --alert-bg: #f7e4da;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ivory);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.72), transparent 26rem),
    var(--ivory);
  color: var(--olive);
  font-family: Tahoma, Arial, "Segoe UI", sans-serif;
  font-size: 1.06rem;
  line-height: 1.7;
}

button {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
.parts-grid:focus-visible {
  outline: 3px solid #b5842d;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 20;
  padding: 0.65rem 0.9rem;
  border-radius: 0.5rem;
  background: var(--olive);
  color: #fff;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(100%, 46rem);
  margin-inline: auto;
  padding: calc(1.25rem + env(safe-area-inset-top, 0px)) clamp(0.7rem, 3.5vw, 1.25rem) calc(2.5rem + var(--safe-bottom));
}

.masthead {
  padding: 1.5rem 0 1.3rem;
  text-align: center;
}

.identity,
.eyebrow,
.masthead h1,
.dedication,
.intro {
  margin: 0;
}

.identity {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.ornament {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: min(13rem, 58vw);
  margin: 0.7rem auto 1rem;
  color: var(--gold);
}

.ornament::before,
.ornament::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--gold-pale);
}

.ornament span {
  font-size: 0.7rem;
  transform: rotate(45deg);
}

.eyebrow {
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.masthead h1 {
  margin-top: 0.2rem;
  font-family: "Scheherazade New", Tahoma, serif;
  font-size: clamp(2.55rem, 12vw, 4.1rem);
  font-weight: 400;
  line-height: 1.2;
}

.dedication {
  color: var(--gold);
  font-size: clamp(1.05rem, 4.7vw, 1.25rem);
  font-weight: 700;
}

.intro {
  max-width: 34rem;
  margin: 0.8rem auto 0;
  color: var(--olive-soft);
  font-size: 1rem;
  line-height: 1.8;
}

/* Progress */
.progress-card,
.guidance,
.completion {
  padding: 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 1rem;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 0 0.45rem 1.4rem rgba(38, 60, 49, 0.06);
}

.progress-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.2rem 1rem;
}

.progress-heading h2,
.progress-heading p {
  margin: 0;
}

.progress-heading h2 {
  font-size: 1.2rem;
}

.progress-count {
  color: var(--gold);
  font-weight: 700;
}

.progress-track {
  height: 0.95rem;
  margin-top: 0.75rem;
  overflow: hidden;
  border-radius: 999px;
  background: #ece2c9;
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--olive-soft));
  transition: width 0.4s ease;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 0.8rem 0 0;
  padding: 0;
  color: var(--olive-soft);
  font-size: 0.92rem;
  list-style: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend b {
  color: var(--olive);
}

.history-line {
  margin: 0.7rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule);
  color: var(--olive-soft);
  font-size: 0.95rem;
}

.swatch {
  width: 1rem;
  height: 1rem;
  border: 1px solid var(--gold-pale);
  border-radius: 0.3rem;
  background: var(--paper);
}

.swatch.is-reserved {
  background: var(--reserved);
}

.swatch.is-completed {
  border-color: #b9cbb6;
  background: var(--completed);
}

/* Notices and states */
.notice {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-inline-start: 4px solid var(--gold);
  border-radius: 0.35rem 0.8rem 0.8rem 0.35rem;
  background: #f6ecd4;
  font-size: 1rem;
}

.notice.is-warning {
  border-color: var(--alert);
  background: var(--alert-bg);
  color: #5a2716;
}

.notice.is-success {
  border-color: var(--completed-ink);
  background: var(--completed);
  color: var(--completed-ink);
}

.parts-section {
  margin-top: 1.4rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.25rem;
}

.section-heading p {
  margin: 0.1rem 0 0.9rem;
  color: var(--olive-soft);
  font-size: 0.95rem;
}

.state-panel {
  padding: 1.6rem 1rem;
  border: 1px dashed var(--gold-pale);
  border-radius: 1rem;
  background: rgba(255, 250, 240, 0.7);
  color: var(--olive-soft);
  text-align: center;
}

.state-panel p {
  margin: 0 0 0.9rem;
}

.state-panel.is-error {
  border-color: var(--alert);
  background: var(--alert-bg);
  color: #5a2716;
}

.spinner {
  display: block;
  width: 2.2rem;
  height: 2.2rem;
  margin: 0 auto 0.8rem;
  border: 3px solid var(--gold-pale);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Parts grid: 3 columns on phones (10 rows), 5 on wider screens (6 rows). */
.parts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

@media (min-width: 560px) {
  .parts-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.7rem;
  }
}

.part-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 6.4rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.6rem 0.3rem;
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  background: var(--paper);
  color: var(--olive);
  text-align: center;
}

button.part-card {
  cursor: pointer;
}

.part-card.is-lapsed {
  border: 2px dashed var(--alert);
}

.part-card.is-lapsed .part-status {
  color: var(--alert);
}

button.part-card:active {
  transform: scale(0.98);
}

.part-label {
  color: var(--olive-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.part-number {
  font-family: "Scheherazade New", Tahoma, serif;
  font-size: 2rem;
  line-height: 1.1;
}

.part-status {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.35;
}

.part-card.is-available .part-status {
  color: var(--gold);
}

.part-card.is-reserved {
  border-color: #e3cf9f;
  background: var(--reserved);
}

.part-card.is-reserved .part-status {
  color: #6b5426;
}

.part-time {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
}

.part-card.is-mine {
  border: 2px solid var(--gold);
  background: #f6e7c1;
  box-shadow: 0 0.3rem 0.9rem rgba(155, 122, 61, 0.22);
}

.part-card.is-completed {
  border-color: #b9cbb6;
  background: var(--completed);
  color: var(--completed-ink);
}

.part-card.is-completed .part-status,
.part-card.is-completed .part-label {
  color: var(--completed-ink);
}

.done-mark {
  position: absolute;
  inset-block-start: 0.35rem;
  inset-inline-end: 0.35rem;
  display: grid;
  width: 1.45rem;
  height: 1.45rem;
  place-items: center;
  border-radius: 50%;
  background: var(--completed-ink);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
}

/* Completion */
.completion {
  margin-top: 1rem;
  padding: 1.6rem 1.2rem;
  border-color: #b9cbb6;
  background: linear-gradient(180deg, #f1f5ee, var(--paper));
  text-align: center;
}

.completion-mark {
  display: grid;
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto 0.6rem;
  place-items: center;
  border-radius: 50%;
  background: var(--completed-ink);
  color: #fff;
  font-size: 1.7rem;
}

.completion h2 {
  margin: 0;
  font-size: 1.35rem;
}

.completion p {
  margin: 0.5rem 0 0;
}

.completion-dua {
  margin-top: 1rem !important;
  font-family: "Scheherazade New", Tahoma, serif;
  font-size: 1.6rem;
  line-height: 1.9;
}

.completion-dua-label {
  color: var(--olive-soft);
  font-size: 0.85rem;
}

.completion-next {
  margin-top: 1rem !important;
  padding-top: 0.9rem;
  border-top: 1px solid #cfdccb;
  font-weight: 700;
}

/* Buttons */
.primary-button,
.secondary-button,
.quiet-button {
  display: block;
  width: 100%;
  min-height: 3.4rem;
  padding: 0.7rem 1rem;
  border-radius: 0.8rem;
  font-size: 1.08rem;
  font-weight: 700;
  cursor: pointer;
}

a.primary-button,
a.secondary-button {
  display: grid;
  place-items: center;
  text-align: center;
  text-decoration: none;
}

.primary-button {
  margin-top: 1.1rem;
  border: 0;
  background: var(--olive);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--gold);
  background: var(--paper);
  color: var(--olive);
}

.quiet-button {
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--olive-soft);
}

.danger-button {
  border-color: var(--alert);
  color: var(--alert);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Dialog */
.part-dialog {
  width: min(calc(100% - 1.5rem), 28rem);
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--gold-pale);
  border-radius: 1.2rem;
  background: var(--paper);
  color: var(--olive);
  box-shadow: 0 1.2rem 3rem rgba(38, 60, 49, 0.25);
}

.part-dialog::backdrop {
  background: rgba(38, 60, 49, 0.45);
}

.dialog-body {
  padding: 1.4rem 1.2rem 1.2rem;
}

.dialog-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 700;
}

.dialog-body h2 {
  margin: 0.1rem 0 0;
  font-family: "Scheherazade New", Tahoma, serif;
  font-size: 2.1rem;
  font-weight: 400;
  line-height: 1.3;
}

.dialog-text {
  margin: 0.6rem 0 0;
  color: var(--olive-soft);
  line-height: 1.8;
}

.dialog-error {
  margin: 0.8rem 0 0;
  padding: 0.7rem 0.8rem;
  border-radius: 0.6rem;
  background: var(--alert-bg);
  color: #5a2716;
}

.dialog-actions {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.dialog-actions .primary-button {
  margin-top: 0;
}

/* Guidance */
.guidance {
  margin-top: 1.4rem;
}

.guidance h2 {
  margin: 0;
  font-size: 1.15rem;
}

.guidance ol {
  margin: 0.5rem 0 0;
  padding-inline-start: 1.5rem;
  list-style-type: arabic-indic;
}

.guidance li {
  margin-top: 0.35rem;
}

.privacy-note {
  margin: 0.8rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--rule);
  color: var(--olive-soft);
  font-size: 0.92rem;
}

footer {
  padding: 2.2rem 0 0.7rem;
  color: var(--olive-soft);
  font-size: 0.85rem;
  text-align: center;
}

footer p {
  margin: 0.2rem 0;
}

noscript {
  display: block;
  padding: 1rem;
  background: #fff1c8;
  color: #442f16;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .progress-fill,
  .spinner {
    transition: none;
    animation: none;
  }
}
