/* Forma — styles
   Paper/Ink/Glaze/Clay palette, Georgia display + system sans body.
*/

:root {
  --paper: #efe9de;
  --paper-deep: #e3dbc9;
  --paper-edge: #d8cdb6;
  --ink: #26211d;
  --ink-soft: #5b5349;
  --glaze: #3e5c63;
  --glaze-deep: #23383c;
  --glaze-tint: #dde6e6;
  --clay: #9c5233;
  --clay-deep: #7a3e26;
  --clay-tint: #ecdcd0;

  --cat-ceramics: #3e5c63;
  --cat-painting: #b23a2e;
  --cat-floristry: #c97a1b;
  --cat-baking: #7a4b27;

  --font-display: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --radius-s: 3px;
  --radius-m: 6px;
  --focus-ring: 0 0 0 2px var(--paper), 0 0 0 4px var(--glaze-deep);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.15  0 0 0 0 0.13  0 0 0 0 0.11  0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  margin: 0;
  color: var(--ink);
}

p {
  margin: 0;
}

button {
  font-family: inherit;
}

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

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-s);
  z-index: 100;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 1rem;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

a:focus-visible,
input:focus-visible,
select:focus-visible,
.item-title:focus-visible {
  border-radius: var(--radius-s);
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--paper-edge);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.7rem;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}

.wordmark:hover {
  color: var(--glaze-deep);
}

.controls {
  display: flex;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.field input[type='search'],
.field select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-s);
  background: #fff;
  color: var(--ink);
  min-width: 15rem;
}

.field select {
  min-width: 10rem;
}

.field input[type='search']::-webkit-search-cancel-button {
  cursor: pointer;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: 1px solid var(--paper-edge);
  color: var(--ink);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.toggle-chip svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.toggle-chip[aria-pressed='true'] {
  background: var(--glaze-deep);
  border-color: var(--glaze-deep);
  color: var(--paper);
}

.toggle-chip:hover {
  border-color: var(--glaze-deep);
}

/* ---------- Hero ---------- */

.hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: 3.2rem 1.5rem 2.6rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  gap: 3rem;
  align-items: center;
}

.hero-text h1 {
  font-size: 3rem;
  line-height: 1.08;
  max-width: 12ch;
  letter-spacing: -0.01em;
}

.hero-text p {
  margin-top: 1.1rem;
  max-width: 42ch;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.55;
}

.hero-swatches {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.1rem 1.4rem;
  padding: 0.5rem 1rem;
}

.hero-swatches img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-m);
  border: 6px solid #fff;
  box-shadow: 0 8px 20px rgba(38, 33, 29, 0.18);
}

.hero-swatches img:nth-child(1) { transform: rotate(-3deg); }
.hero-swatches img:nth-child(2) { transform: rotate(2deg); margin-top: 1.4rem; }
.hero-swatches img:nth-child(3) { transform: rotate(2.5deg); margin-top: -1.4rem; }
.hero-swatches img:nth-child(4) { transform: rotate(-2deg); }

/* ---------- Listing ---------- */

.listing {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.listing-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--paper-edge);
  padding-bottom: 0.8rem;
  margin-bottom: 0.4rem;
}

.listing-head h2 {
  font-size: 1.4rem;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: flex;
  gap: 1.5rem;
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--paper-edge);
  align-items: center;
}

.item-media {
  position: relative;
  flex-shrink: 0;
  width: 132px;
  height: 132px;
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--paper-deep);
}

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

.cat-dot {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.cat-ceramics { background: var(--cat-ceramics); }
.cat-painting { background: var(--cat-painting); }
.cat-floristry { background: var(--cat-floristry); }
.cat-baking { background: var(--cat-baking); }

.item-body {
  flex: 1;
  min-width: 0;
}

.item-cat {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 0.25rem;
}

.item-title {
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
}

.item-summary {
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 60ch;
  margin-bottom: 0.65rem;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  font-size: 0.87rem;
  color: var(--ink);
}

.item-meta span {
  padding: 0 0.85rem;
  border-left: 1px solid var(--paper-edge);
}

.item-meta span:first-child {
  padding-left: 0;
  border-left: none;
}

.saved-badge {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--clay-deep);
  background: var(--clay-tint);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-s);
}

.item-action {
  flex-shrink: 0;
}

.open-item-btn {
  background: var(--glaze-deep);
  color: var(--paper);
  border: none;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-s);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.open-item-btn:hover {
  background: #17272a;
}

/* ---------- Empty state ---------- */

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  border: 1px dashed var(--paper-edge);
  border-radius: var(--radius-m);
  margin-top: 1rem;
}

.empty-state p {
  color: var(--ink-soft);
  margin-bottom: 1rem;
  font-size: 1rem;
}

.empty-state button {
  background: var(--glaze-deep);
  color: var(--paper);
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 0.9rem;
}

/* ---------- Detail dialog ---------- */

dialog.detail {
  border: none;
  padding: 0;
  border-radius: var(--radius-m);
  width: min(600px, 92vw);
  max-height: 88vh;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(38, 33, 29, 0.35);
}

dialog.detail::backdrop {
  background: rgba(38, 33, 29, 0.55);
}

@media (prefers-reduced-motion: no-preference) {
  dialog.detail[open] {
    animation: detail-in 0.22s ease-out;
  }
}

@keyframes detail-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.detail-inner {
  padding: 1.5rem 1.6rem 1.8rem;
  overflow-y: auto;
  max-height: 88vh;
  position: relative;
}

.detail-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--paper-edge);
  background: var(--paper);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-close:hover {
  background: var(--paper-deep);
}

.detail-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: var(--radius-m);
  margin-bottom: 1.1rem;
}

.detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}

.detail-chip .cat-dot {
  position: static;
  border: none;
}

.detail-title {
  font-size: 1.9rem;
  line-height: 1.1;
  margin-bottom: 0.4rem;
  padding-right: 2rem;
}

.detail-instructor {
  color: var(--ink-soft);
  font-size: 0.98rem;
  margin-bottom: 1.2rem;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem 1.2rem;
  margin: 0 0 1.3rem;
  padding: 1rem 1.1rem;
  background: var(--paper-deep);
  border-radius: var(--radius-m);
}

.detail-facts div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.detail-facts dt {
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.detail-facts dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.detail-body {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 1.5rem;
}

.save-toggle {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-s);
  border: 1px solid var(--glaze-deep);
  background: transparent;
  color: var(--glaze-deep);
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.save-toggle[aria-pressed='true'] {
  background: var(--glaze-deep);
  color: var(--paper);
}

.save-toggle:hover {
  background: var(--glaze-tint);
}

.save-toggle[aria-pressed='true']:hover {
  background: #17272a;
}

/* ---------- Footer ---------- */

footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  border-top: 1px solid var(--paper-edge);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 2.2rem;
  }

  .hero-swatches {
    max-width: 22rem;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 0.75rem 1.1rem;
  }

  .wordmark {
    font-size: 1.4rem;
  }

  .controls {
    width: 100%;
    gap: 0.7rem;
  }

  .field {
    flex: 1 1 100%;
  }

  .field input[type='search'],
  .field select {
    width: 100%;
    min-width: 0;
  }

  .toggle-chip {
    width: 100%;
    justify-content: center;
  }

  .hero {
    padding: 2rem 1.1rem 2rem;
    gap: 1.8rem;
  }

  .hero-text h1 {
    font-size: 2.1rem;
    max-width: none;
  }

  .hero-swatches {
    max-width: none;
    gap: 0.8rem 1rem;
  }

  .listing {
    padding: 0 1.1rem 3rem;
  }

  .item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.9rem;
    padding: 1.4rem 0;
  }

  .item-media {
    width: 100%;
    height: 180px;
  }

  .item-action {
    width: 100%;
  }

  .open-item-btn {
    width: 100%;
  }

  dialog.detail {
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .detail-inner {
    max-height: 100vh;
    padding: 1.2rem 1.1rem 2rem;
  }

  .detail-facts {
    grid-template-columns: repeat(2, 1fr);
  }
}

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