/* Markarium — a warm, archival visual language without external assets. */
:root {
  color-scheme: light;
  --paper: #f8f0dc;
  --paper-light: #fffaf0;
  --parchment: #e9d5ad;
  --ink: #392413;
  --ink-soft: #654b36;
  --brown: #4b2c17;
  --brown-deep: #29180e;
  --gold: #b18230;
  --gold-light: #e9c983;
  --line: #d9c4a1;
  --success: #22583f;
  --danger: #922f2b;
  --shadow: 0 12px 32px rgb(57 36 19 / 9%);
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  background: radial-gradient(ellipse at 50% 0, #fff8e9 0, transparent 65%), var(--paper);
  color: var(--ink);
}
img, svg { max-width: 100%; }
img { height: auto; }
a { color: #70401b; text-underline-offset: .2em; }
a:hover { color: var(--brown-deep); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #a45b15; outline-offset: 3px; }
::selection { background: var(--gold-light); color: var(--brown-deep); }
h1, h2, h3, h4 {
  margin: 0 0 .65em;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.16;
  color: var(--brown-deep);
}
h1 { font-size: clamp(2rem, 5vw, 3.35rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
.container { width: min(100% - 2rem, 1200px); margin-inline: auto; }
.muted { color: var(--ink-soft); }
.notice, .alert { padding: .9rem 1.15rem; border-radius: 8px; margin-block: 1rem; }
.notice { border-left: 4px solid var(--gold); background: #f4e6c8; }
.alert { border: 1px solid #c8a877; background: #fff4da; }
.alert.success { border-color: #93b59e; background: #e6f2e9; color: var(--success); }
.alert.error, .alert.danger { border-color: #d6a29a; background: #fbeae7; color: var(--danger); }

.site-header {
  background: var(--brown-deep);
  color: var(--paper-light);
  border-bottom: 4px solid var(--gold);
}
.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 2rem;
  padding-block: .85rem;
}
.site-header a { color: #fff3d7; text-decoration: none; }
.site-header a:hover { color: var(--gold-light); }
.site-header .brand, .site-header .logo {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: .035em;
}
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .45rem; }
.site-nav a { display: inline-block; padding: .45rem .7rem; border-radius: 6px; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: #674529; color: #fff; }

main { padding-block: 2rem 3.5rem; }
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(2rem, 5vw, 4.5rem);
  margin-bottom: 2.5rem;
  border: 1px solid #d7b981;
  border-radius: var(--radius);
  background: radial-gradient(circle at 85% 10%, rgb(255 252 232 / 80%), transparent 42%),
    repeating-linear-gradient(135deg, rgb(104 63 22 / 2%) 0 2px, transparent 2px 6px),
    linear-gradient(135deg, #f7e6c1, #e8cb97);
  box-shadow: var(--shadow);
}
.hero::after { content: ""; position: absolute; inset: 10px; border: 1px solid rgb(92 55 23 / 18%); border-radius: 6px; pointer-events: none; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 1.5rem; }
.hero > * { position: relative; z-index: 1; }
.hero > img { width: 100%; max-height: 340px; object-fit: contain; mix-blend-mode: multiply; }
.hero p { max-width: 62ch; font-size: 1.1rem; }
.hero .button { margin-top: .5rem; }

.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem 1rem; margin-block: 1.25rem; }
.toolbar > * { min-width: 0; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 245px), 1fr)); gap: 1.25rem; }
.product-card, .panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-light);
  box-shadow: var(--shadow);
}
.product-card { display: flex; flex-direction: column; overflow: hidden; }
.product-body { display: flex; flex: 1; flex-direction: column; padding: 1rem 0; }
.product-body .product-bottom { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-top: auto; }
.product-body .price { padding: 0; }
.product-body .button-secondary { margin: 0; }
.product-card > :not(.product-image) { margin-inline: 1rem; }
.product-card h2, .product-card h3 { margin-top: 1rem; font-size: 1.2rem; }
.product-card h2 a, .product-card h3 a { color: inherit; text-decoration: none; }
.product-card h2 a:hover, .product-card h3 a:hover { text-decoration: underline; }
.product-card .price { margin-top: auto; padding-top: .7rem; }
.product-card .button, .product-card .button-secondary { align-self: flex-start; margin-block: .6rem 1.1rem; }
.product-image {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #eee1c8;
  border-bottom: 1px solid var(--line);
}
.product-image img { width: 100%; height: 100%; object-fit: contain; }
.badge { display: inline-block; width: fit-content; padding: .2rem .55rem; border-radius: 4px; background: #e9d6a9; color: var(--brown-deep); font-size: .78rem; font-weight: 700; letter-spacing: .025em; }
.price { color: var(--brown-deep); font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.panel { padding: clamp(1rem, 3vw, 2rem); margin-bottom: 1.5rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: .75rem; }
.gallery img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; padding: .5rem; border: 1px solid var(--line); border-radius: 8px; background: #f3e8d1; }
.gallery > :first-child { grid-column: 1 / -1; }
.gallery > :first-child img, .gallery > img:first-child { aspect-ratio: 4 / 3; max-height: 500px; }
.gallery a { cursor: zoom-in; }
.gallery a:focus-visible { border-radius: 8px; }

body.viewer-open { overflow: hidden; }
.photo-viewer[hidden] { display: none; }
.photo-viewer {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #20150e;
  color: #fff3dc;
}
.viewer-header, .viewer-toolbar {
  display: flex;
  align-items: center;
  flex: none;
  gap: .5rem;
  padding: .7rem clamp(.75rem, 3vw, 1.75rem);
  background: #2b1c12;
}
.viewer-header { justify-content: space-between; }
.viewer-counter { font-variant-numeric: tabular-nums; }
.viewer-toolbar { justify-content: center; flex-wrap: wrap; }
.viewer-control {
  min-width: 44px;
  min-height: 44px;
  padding: .35rem .75rem;
  border: 1px solid #b69b77;
  border-radius: 7px;
  background: #46301f;
  color: #fff9ed;
  font-size: 1.4rem;
  line-height: 1;
}
.viewer-control:hover { background: #68462b; }
.viewer-control:disabled { opacity: .45; cursor: not-allowed; }
.viewer-text-control { font-size: .9rem; font-weight: 600; }
.viewer-close { font-size: 1.8rem; }
.viewer-divider { width: 1px; height: 30px; background: #775d43; margin-inline: .25rem; }
.viewer-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: default;
}
.viewer-viewport.can-pan { cursor: grab; }
.viewer-viewport.can-pan:active { cursor: grabbing; }
.viewer-image {
  position: absolute;
  top: 50%;
  left: 50%;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  transform-origin: center center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.button, .button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .58rem 1.05rem;
  border: 1px solid var(--brown);
  border-radius: 7px;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.button { background: var(--brown); color: #fffaf0; }
.button:hover { background: #694020; color: #fff; transform: translateY(-1px); }
.button-secondary { background: transparent; color: var(--brown); }
.button-secondary:hover { background: #f2e1c1; color: var(--brown-deep); }
.button:disabled, .button-secondary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field label, label.field { font-weight: 650; }
.field input, .field select, .field textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
select, textarea {
  width: 100%; min-width: 0; min-height: 44px; padding: .6rem .75rem;
  border: 1px solid #a88c67; border-radius: 6px; background: #fffdf8; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brown); width: 1.1em; height: 1.1em; vertical-align: middle; }
input:disabled, select:disabled, textarea:disabled { opacity: .65; cursor: not-allowed; }
.field:has(textarea), .field.full-width { grid-column: 1 / -1; }

.table-wrap { width: 100%; overflow-x: auto; border-radius: 8px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--paper-light); font-variant-numeric: tabular-nums; }
th, td { padding: .75rem .85rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #ebd7b3; color: var(--brown-deep); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.cart-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto auto; gap: .75rem 1rem; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.cart-row:last-child { border-bottom: 0; }
.cart-row img { max-width: 90px; max-height: 90px; object-fit: contain; }

.admin-layout { display: grid; grid-template-columns: minmax(190px, 235px) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.admin-layout > * { min-width: 0; }
.sidebar { display: flex; flex-direction: column; gap: .25rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: #ead8b6; }
.sidebar a { display: block; padding: .55rem .75rem; border-radius: 6px; text-decoration: none; font-weight: 600; }
.sidebar a:hover, .sidebar a[aria-current="page"] { background: var(--brown); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stats > * { padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-light); box-shadow: var(--shadow); }
.stats strong { display: block; font-size: 1.7rem; color: var(--brown-deep); font-variant-numeric: tabular-nums; }
.footer { padding: 2rem 0; border-top: 3px solid var(--gold); background: var(--brown-deep); color: #f8e8c9; }
.footer a { color: #f9dda6; }

@media (max-width: 760px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .site-header .container { justify-content: center; text-align: center; }
  .site-nav { justify-content: center; }
  .hero { grid-template-columns: 1fr; }
  .hero > img { max-height: 230px; }
  main { padding-block: 1.4rem 2.5rem; }
}
@media (max-width: 540px) {
  .container { width: min(100% - 1.25rem, 1200px); }
  .hero { padding: 1.6rem 1.25rem; grid-template-columns: 1fr; }
  .hero > img { max-height: 180px; }
  .form-grid { grid-template-columns: 1fr; }
  .field:has(textarea), .field.full-width { grid-column: auto; }
  .toolbar > .field { flex: 1 1 100%; }
  .cart-row { grid-template-columns: 70px minmax(0, 1fr); }
  .cart-row > :first-child { grid-column: auto; }
  .site-nav a { padding: .4rem .5rem; }
  .viewer-header, .viewer-toolbar { gap: .35rem; padding: .5rem; }
  .viewer-control { padding: .3rem .55rem; }
  .viewer-divider { display: none; }
  .panel { padding: 1rem; }
  .table-wrap th, .table-wrap td { padding: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
