:root {
  --ink: #17211d;
  --muted: #68736e;
  --line: rgba(23, 33, 29, 0.15);
  --paper: #f8f4eb;
  --white: #fffdf8;
  --red: #d75538;
  --red-dark: #a93d29;
  --green: #12392f;
  --green-dark: #09251f;
  --jade-soft: #dce9df;
  --yellow: #d9a441;
  --radius: 12px;
  --shadow: 0 20px 54px rgba(20, 34, 28, 0.12);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Nunito Sans", "Trebuchet MS", sans-serif;
  font-synthesis: none;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(215, 53, 37, 0.3);
  outline-offset: 2px;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 68px;
  padding: 0 4vw;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--white);
  background: rgba(9, 37, 31, 0.95);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  letter-spacing: 0.08em;
}

.brand span {
  padding: 5px 7px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--yellow);
  font-weight: 900;
}

.topbar__stats {
  display: flex;
  gap: 24px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar__stats b {
  color: var(--white);
}

main {
  overflow: hidden;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.6fr);
  gap: 6vw;
  min-height: 620px;
  padding: 100px 5vw 84px;
  color: var(--white);
  background:
    linear-gradient(90deg, rgba(9, 37, 31, 0.96), rgba(9, 37, 31, 0.72)),
    url("https://commons.wikimedia.org/wiki/Special:Redirect/file/Lake%20Kanas.jpg?width=1800") center / cover;
}

.hero > div:first-child {
  align-self: center;
  max-width: 850px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.hero h1 {
  max-width: 850px;
  margin: 0;
  font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
  font-size: clamp(58px, 8vw, 118px);
  font-weight: 500;
  line-height: 0.88;
  letter-spacing: -0.055em;
}

.hero__lead {
  max-width: 660px;
  margin: 34px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.55;
}

.period {
  align-self: center;
  display: grid;
  gap: 16px;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 22px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 26px 80px rgba(3, 18, 14, 0.28);
  backdrop-filter: blur(14px);
}

.period__heading,
.section-index {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.period__heading > span,
.section-index > span {
  min-width: 44px;
  padding-top: 4px;
  color: var(--red);
  font-weight: 900;
}

.period__heading p,
.section-index p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.period__heading strong {
  font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 500;
}

.period label,
.filters label,
.taste__heading {
  display: grid;
  gap: 7px;
}

.period label > span,
.filters label > span,
.taste__heading > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 13px;
  color: var(--ink);
  background: var(--white);
}

.period button,
.filters__footer button,
.empty button,
.load-more {
  min-height: 44px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.period__note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.filters,
.catalog-section {
  padding: 74px 5vw;
}

.filters {
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.section-index h2 {
  margin: 0;
  font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
  font-size: clamp(30px, 4vw, 54px);
  font-weight: 500;
  letter-spacing: -0.045em;
}

.filters__primary {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 42px;
}

.taste {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 20px;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.taste__heading small {
  max-width: 130px;
  color: var(--muted);
  line-height: 1.4;
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-filter {
  min-height: 35px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  color: var(--green);
  background: var(--paper);
  font-size: 12px;
  font-weight: 700;
}

.tag-filter span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tag-filter[aria-pressed="true"] {
  border-color: var(--green);
  color: var(--white);
  background: var(--green);
}

.tag-filter[aria-pressed="true"] span {
  color: rgba(255, 255, 255, 0.65);
}

.filters__footer {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 30px;
}

.selected-toggle {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
}

.selected-toggle input {
  width: 18px;
  min-height: 18px;
}

.filters__footer p {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.catalog-section {
  min-height: 600px;
}

.catalog {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
  margin-top: 42px;
}

.card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: var(--white);
  box-shadow: var(--shadow);
  transition:
    transform 240ms ease,
    box-shadow 240ms ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 25px 64px rgba(20, 34, 28, 0.17);
}

.card__open {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
}

.card__image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #dfe3e4;
}

.card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 240ms ease;
}

.card:hover .card__image img {
  transform: scale(1.025);
}

.card__rank,
.card__season {
  position: absolute;
  top: 10px;
  padding: 6px 8px;
  color: var(--white);
  border-radius: 999px;
  background: rgba(9, 37, 31, 0.82);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  backdrop-filter: blur(10px);
}

.card__rank {
  left: 10px;
}

.card__season {
  right: 10px;
  background: var(--green);
}

.card__season--partial {
  color: var(--ink);
  background: var(--yellow);
}

.card__body {
  padding: 20px;
}

.card__meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card h3 {
  min-height: 2.4em;
  margin: 12px 0 5px;
  font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.card__chinese {
  min-height: 1.4em;
  margin: 0;
  color: var(--red);
  font-family: "Songti SC", "STSong", serif;
  font-size: 13px;
}

.card__description {
  display: -webkit-box;
  overflow: hidden;
  min-height: 4.3em;
  margin: 14px 0;
  color: #4f5c56;
  font-size: 13px;
  line-height: 1.45;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: 5px;
  min-height: 50px;
}

.card__tags span,
.details__tags span {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green);
  background: var(--jade-soft);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.card__footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
}

.card__months {
  color: var(--muted);
  font-size: 11px;
}

.card__select {
  min-width: 36px;
  min-height: 36px;
  border: 1px solid var(--green);
  border-radius: 50%;
  color: var(--green);
  background: transparent;
  font-size: 17px;
  font-weight: 900;
}

.card__select[aria-pressed="true"] {
  color: var(--white);
  background: var(--red);
  border-color: var(--red);
}

.load-more {
  display: block;
  margin: 34px auto 0;
  background: var(--white);
  box-shadow: 0 10px 28px rgba(20, 34, 28, 0.08);
}

.empty {
  margin: 50px 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 50px;
  text-align: center;
  background: var(--white);
}

.empty strong {
  font-size: 28px;
}

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

footer {
  display: grid;
  grid-template-columns: 1fr 1.5fr auto;
  gap: 40px;
  padding: 54px 5vw 100px;
  color: rgba(255, 255, 255, 0.68);
  background: var(--green-dark);
  font-size: 13px;
  line-height: 1.6;
}

footer strong {
  color: var(--white);
  font-size: 20px;
}

footer a {
  color: var(--yellow);
}

dialog {
  border: 0;
  border-radius: 22px;
  padding: 0;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.36);
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(7, 12, 16, 0.78);
  backdrop-filter: blur(4px);
}

.details-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
}

.dialog-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: var(--white);
  background: rgba(16, 24, 32, 0.88);
  font-size: 25px;
}

.details {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.details__image {
  min-height: 620px;
  background: #dde1e2;
}

.details__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.details__content {
  padding: 50px;
}

.details__content h2 {
  margin: 12px 0 6px;
  font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 58px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.details__chinese {
  color: var(--red);
}

.details__description {
  margin: 28px 0;
  color: #4f5c56;
  font-size: 16px;
  line-height: 1.6;
}

.details__facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.details__facts div {
  padding: 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.details__facts small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  text-transform: uppercase;
}

.details__tags {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  margin: 24px 0;
}

.details__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.details__actions a,
.details__actions button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--ink);
  text-decoration: none;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.details__actions .primary {
  color: var(--white);
  background: var(--ink);
}

.reset-dialog {
  width: min(460px, calc(100vw - 32px));
}

.reset-dialog > div {
  padding: 34px;
}

.reset-dialog h2 {
  margin: 0;
  font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.reset-dialog p:not(.eyebrow) {
  color: var(--muted);
}

.reset-dialog__actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
}

.reset-dialog__actions button {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: transparent;
  font-weight: 800;
}

.reset-dialog__actions .danger {
  border-color: var(--red);
  color: var(--white);
  background: var(--red);
}

.selection-bar {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  display: flex;
  gap: 18px;
  align-items: center;
  border-radius: 999px;
  padding: 9px 9px 9px 18px;
  color: var(--white);
  background: var(--green-dark);
  box-shadow: 0 18px 60px rgba(16, 24, 32, 0.3);
}

.selection-bar > div {
  display: flex;
  gap: 6px;
}

.selection-bar button {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--white);
  font-size: 11px;
  font-weight: 800;
}

.selection-bar .selection-reset {
  color: var(--white);
  background: var(--red);
}

noscript {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  color: var(--white);
  background: var(--ink);
}

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

  .filters__primary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .topbar__stats span:first-child {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-top: 70px;
  }

  .period {
    max-width: 560px;
  }

  .taste {
    grid-template-columns: 1fr;
  }

  .catalog {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .details {
    grid-template-columns: 1fr;
  }

  .details__image {
    min-height: 350px;
    max-height: 48vh;
  }

  footer {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding-inline: 16px;
  }

  .hero {
    padding: 58px 18px 44px;
  }

  .hero h1 {
    font-size: 53px;
  }

  .period {
    padding: 22px;
  }

  .filters,
  .catalog-section {
    padding: 48px 16px;
  }

  .filters__primary,
  .catalog {
    grid-template-columns: 1fr;
  }

  .filters__footer {
    align-items: stretch;
    flex-direction: column;
  }

  .filters__footer p {
    margin-left: 0;
  }

  .card h3,
  .card__description,
  .card__tags {
    min-height: 0;
  }

  .selection-bar {
    right: 10px;
    bottom: 10px;
    left: 10px;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    border-radius: 20px;
    padding: 10px;
  }

  .selection-bar > strong {
    text-align: center;
  }

  .selection-bar > div {
    display: grid;
    grid-template-columns: 0.8fr 1.5fr 0.8fr;
  }

  .selection-bar button {
    padding-inline: 6px;
  }

  .details__content {
    padding: 32px 22px;
  }

  .details__facts {
    grid-template-columns: 1fr;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
