@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Libre+Caslon+Display&display=swap");

:root {
  color-scheme: light;
  --paper: #f3edda;
  --ink: #202b29;
  --orange: #b84123;
  --line: #c9c5b2;
  --muted: #62685d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
  font-size: 16px;
}

body:before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23000' filter='url(%23n)' opacity='.25' d='M0 0h180v180H0z'/%3E%3C/svg%3E");
}

header,
main,
footer {
  width: min(1180px, calc(100% - 80px));
  margin: auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 0;
  border-bottom: 1px solid var(--ink);
}

.brand {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: inherit;
  text-decoration: none;
}

.brand span {
  display: block;
  font-weight: 400;
  letter-spacing: 0.04em;
  font-size: 12px;
  margin-top: 4px;
}

.edition,
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.welcome {
  text-align: center;
  padding: 72px 0 32px;
}

.eyebrow {
  color: var(--orange);
  margin: 0 0 18px;
}

h1 {
  font-family: "Libre Caslon Display", Georgia, serif;
  font-weight: 400;
  font-size: clamp(48px, 6.4vw, 86px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  margin: 0 0 24px;
}

h1 em {
  font-weight: 400;
  color: var(--orange);
}

.intro {
  color: var(--muted);
  line-height: 1.8;
  margin: 24px 0 30px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

button:focus-visible,
a:focus-visible,
audio:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 5px;
}

.primary {
  background: var(--orange);
  color: #fff8e7;
  padding: 17px 24px;
  font-weight: 600;
  border-radius: 3px;
  display: inline-flex;
  gap: 30px;
  justify-content: space-between;
  align-items: center;
  min-height: 54px;
}

.primary:hover {
  background: #97351d;
}

.small {
  font-size: 14px;
  color: var(--muted);
  margin-top: 20px;
}

.decades {
  font-family: Georgia, serif;
  font-size: clamp(50px, 8vw, 100px);
  letter-spacing: -0.07em;
  line-height: 1.3;
  padding: 44px 0 12px;
  color: #a0a18b;
}

.decades span {
  color: #c5c4b0;
  font-weight: 400;
  font-size: 0.6em;
  margin: 0 18px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  padding: 24px 0;
  margin-top: 32px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

footer span:last-child {
  font-family: Georgia, serif;
  font-style: italic;
  letter-spacing: 0;
  font-size: 14px;
}

.chapter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 40px;
  gap: 20px;
}

.chapter-head h1 {
  font-size: 58px;
  margin-bottom: 14px;
}

.chapter-head .eyebrow {
  margin-bottom: 8px;
}

.counter {
  font-family: Georgia, serif;
  font-size: 24px;
  white-space: nowrap;
}

.progress {
  display: flex;
  gap: 7px;
  margin: 8px 0 28px;
}

.progress span {
  height: 4px;
  background: #d6d4c2;
  flex: 1;
}

.progress .complete {
  background: var(--ink);
}

.progress .current {
  background: var(--orange);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
  gap: 32px;
  align-items: start;
}

.picture-frame {
  padding: 14px;
  background: #e8e3d1;
  border: 1px solid #d0ccbb;
}

.picture-frame img {
  display: block;
  width: 100%;
  max-height: 560px;
  object-fit: contain;
}

.picture-frame img[hidden] {
  display: none;
}

.image-placeholder {
  min-height: 330px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed #aaa894;
  background: #f7f2e2;
  padding: 25px;
  text-align: center;
}

.image-placeholder .eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.image-placeholder strong {
  font-family: "Libre Caslon Display", Georgia, serif;
  font-size: 100px;
  line-height: 1;
  color: var(--orange);
  font-weight: 400;
}

.image-placeholder p {
  color: var(--muted);
}

.placeholder-tag {
  font-size: 12px;
  letter-spacing: 0.15em;
  border: 1px solid var(--line);
  padding: 7px 10px;
}

form {
  padding-top: 25px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 12px;
}

.input-row {
  display: flex;
  gap: 10px;
}

input {
  width: 100%;
  min-width: 0;
  background: #faf6e9;
  border: 1px solid #aaa997;
  border-radius: 3px;
  padding: 16px;
  color: var(--ink);
}

input:focus {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

input[aria-invalid="true"] {
  border-color: var(--orange);
}

#feedback[data-type="success"] {
  color: #27633e;
}
#feedback {
  min-height: 24px;
  color: var(--orange);
  font-size: 14px;
  margin: 12px 0 0;
}

.audio-panel {
  background: var(--ink);
  color: #f4edda;
  padding: 28px;
  border-radius: 4px;
  border-top: 5px solid #e3b65f;
}

.audio-panel .eyebrow {
  color: #e4b667;
  font-size: 12px;
}

.record-label {
  border-top: 1px solid #69736a;
  border-bottom: 1px solid #69736a;
  padding: 18px 0;
  margin-top: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.record-dot {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background: #e4b667;
}

.audio-panel h2 {
  font-family: "Libre Caslon Display", Georgia, serif;
  font-size: 34px;
  font-weight: 400;
  margin: 22px 0 12px;
}

.audio-panel p {
  font-size: 14px;
  line-height: 1.7;
  color: #d5d9cd;
}

.audio-panel audio {
  width: 100%;
  margin: 16px 0 10px;
}

.secondary {
  color: #f4edda;
  background: transparent;
  padding: 12px 0;
  text-align: left;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.audio-foot {
  border-top: 1px solid #69736a;
  padding-top: 20px;
  margin-top: 22px;
}

.audio-foot span {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #e4b667;
}

.audio-foot p {
  margin-bottom: 0;
}

#audio-status:empty {
  display: none;
}

.ending {
  text-align: center;
  padding-top: 65px;
}

.ending > p {
  line-height: 1.8;
}

.ending .audio-panel {
  max-width: 470px;
  margin: 35px auto;
  text-align: left;
}

.symbol-mode:before {
  display: none;
}

.symbol-mode main {
  width: 100%;
  animation: none;
}

.symbol-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
}

#symbol-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  object-fit: contain;
}

#symbol-status {
  text-align: center;
}

.image-viewer-open {
  overflow: hidden;
}

#puzzle-image,
#symbol-image {
  cursor: zoom-in;
}

#puzzle-image:focus-visible,
#symbol-image:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 5px;
}

#image-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 76px 16px 16px;
  background: rgba(0, 0, 0, 0.94);
  color: white;
}

#image-viewer[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

#image-viewer::backdrop {
  background: black;
}

#image-viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#image-viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  header,
  main,
  footer {
    width: calc(100% - 36px);
  }

  header {
    padding: 22px 0;
  }

  .brand {
    font-size: 20px;
  }

  .edition {
    display: none;
  }

  .welcome {
    padding-top: 52px;
  }

  .welcome h1 br {
    display: none;
  }

  .intro br {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .chapter-head h1 {
    font-size: 44px;
  }

  .chapter-head {
    padding-top: 28px;
  }

  .image-placeholder {
    min-height: 280px;
  }

  .audio-panel {
    padding: 24px;
  }

  .decades span {
    margin: 0 8px;
  }

  .input-row {
    flex-wrap: wrap;
  }

  .input-row .primary {
    width: 100%;
  }

  footer {
    flex-direction: column;
    gap: 10px;
  }

  .counter {
    font-size: 20px;
  }

  .welcome .primary {
    width: 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  main {
    animation: appear 0.45s ease-out;
  }

  @keyframes appear {
    from {
      opacity: 0;
      transform: translateY(8px);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }
}
