/* Sterling Ice Co. — 1904 ledger-book immersion (realistic leather + parchment pages) */

/* ====================================================================
   DESK — the whole app sits on a candle-lit wooden desk
   ==================================================================== */
body {
  background:
    radial-gradient(42% 30% at 50% 0%, rgba(236, 188, 104, 0.16), transparent 60%),
    radial-gradient(135% 120% at 50% 130%, rgba(0, 0, 0, 0.92), transparent 55%),
    repeating-linear-gradient(91deg, rgba(0, 0, 0, 0.18) 0 4px, transparent 4px 12px),
    linear-gradient(180deg, #2a1f13 0%, #160f08 72%, #0f0a05 100%);
  background-attachment: fixed;
}

/* ====================================================================
   CLOSED COVER that opens in 3D
   ==================================================================== */
.book-cover {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  perspective: 2600px;
  transition: opacity 0.6s ease;
  background:
    radial-gradient(38% 28% at 50% 16%, rgba(236, 188, 104, 0.22), transparent 60%),
    radial-gradient(130% 120% at 50% 130%, rgba(0, 0, 0, 0.92), transparent 55%),
    repeating-linear-gradient(91deg, rgba(0, 0, 0, 0.16) 0 4px, transparent 4px 11px),
    linear-gradient(180deg, #271c12 0%, #181109 70%, #100b06 100%);
}

.book-cover.is-gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.book {
  position: relative;
  width: min(440px, 85vw);
  aspect-ratio: 3 / 4.05;
  transform-style: preserve-3d;
}

.book::after {
  content: "";
  position: absolute;
  left: 6%;
  right: -4%;
  bottom: -6%;
  height: 12%;
  background: radial-gradient(50% 100% at 50% 0%, rgba(0, 0, 0, 0.75), transparent 70%);
  filter: blur(10px);
  z-index: 0;
}

.book__pages {
  position: absolute;
  inset: 0;
  transform: translate(9px, 7px);
  border-radius: 3px 7px 8px 4px;
  background:
    repeating-linear-gradient(0deg, #efe3c6 0 2px, #d9c9a3 2px 3.5px),
    #e7dabd;
  box-shadow: 0 30px 55px rgba(0, 0, 0, 0.6);
  z-index: 1;
}

.book__firstpage {
  position: absolute;
  inset: 0;
  border-radius: 3px 7px 7px 3px;
  background:
    radial-gradient(70% 60% at 50% 40%, rgba(255, 250, 235, 0.9), rgba(228, 214, 182, 0.92)),
    #e9dcc0;
  box-shadow: inset 0 0 60px rgba(120, 95, 55, 0.35);
  display: grid;
  place-items: center;
  z-index: 2;
}

.firstpage-emblem {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "Rye", "Playfair Display", serif;
  font-size: 1.8rem;
  color: #7a5a1e;
  border: 2px solid rgba(122, 90, 30, 0.5);
  opacity: 0.4;
}

.book__cover {
  position: absolute;
  inset: 0;
  z-index: 3;
  transform-origin: left center;
  transform: rotateY(0deg);
  transition: transform 1.2s cubic-bezier(0.2, 0.72, 0.16, 1);
  transform-style: preserve-3d;
  border-radius: 4px 9px 9px 4px;
  background:
    linear-gradient(118deg, rgba(255, 232, 184, 0.12), transparent 32%, rgba(0, 0, 0, 0.28) 92%),
    radial-gradient(125% 95% at 28% 18%, rgba(150, 100, 52, 0.55), transparent 62%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='l'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23l)' opacity='0.45'/%3E%3C/svg%3E"),
    linear-gradient(160deg, #5c3f22 0%, #422c16 55%, #2c1d0f 100%);
  background-blend-mode: overlay, soft-light, overlay, normal;
  box-shadow:
    0 38px 70px rgba(0, 0, 0, 0.65),
    inset 0 0 0 2px rgba(0, 0, 0, 0.35),
    inset 0 0 46px rgba(0, 0, 0, 0.4),
    inset 0 2px 0 rgba(255, 222, 160, 0.1);
}

.book-cover.is-open .book__cover {
  transform: rotateY(-164deg);
  box-shadow: 0 30px 55px rgba(0, 0, 0, 0.55);
}

.book__spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 30px;
  border-radius: 4px 0 0 4px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.04));
  box-shadow: inset -3px 0 6px rgba(0, 0, 0, 0.5);
}

.book__spine::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0 40px,
    rgba(0, 0, 0, 0.5) 40px 44px,
    rgba(255, 220, 160, 0.14) 44px 46px,
    transparent 46px 86px
  );
}

.corner {
  position: absolute;
  width: 54px;
  height: 54px;
  z-index: 4;
  pointer-events: none;
}

.corner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #f0d488 0%, #b58f38 45%, #7a5d1f 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 244, 210, 0.45), 0 1px 3px rgba(0, 0, 0, 0.55);
}

.corner-tl { top: 5px; left: 5px; }
.corner-tl::before { clip-path: polygon(0 0, 100% 0, 0 100%); border-radius: 4px 0 0 0; }
.corner-tr { top: 5px; right: 5px; }
.corner-tr::before { clip-path: polygon(100% 0, 0 0, 100% 100%); border-radius: 0 7px 0 0; }
.corner-bl { bottom: 5px; left: 5px; }
.corner-bl::before { clip-path: polygon(0 100%, 0 0, 100% 100%); border-radius: 0 0 0 4px; }
.corner-br { bottom: 5px; right: 5px; }
.corner-br::before { clip-path: polygon(100% 100%, 100% 0, 0 100%); border-radius: 0 0 7px 0; }

.cover-stitch {
  position: absolute;
  inset: 20px 20px 20px 34px;
  border: 1.5px solid rgba(210, 170, 70, 0.6);
  border-radius: 5px;
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.22), inset 0 0 0 6.5px rgba(210, 170, 70, 0.22);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  backface-visibility: hidden;
}

.cover-eyebrow {
  font-family: "EB Garamond", Georgia, serif;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  font-size: 0.76rem;
  color: #e7c878;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.6));
}

.cover-emblem {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #f6e2a6, #c89a3a 55%, #876618 100%);
  color: #3a2808;
  font-family: "Rye", "Playfair Display", serif;
  font-size: 1.7rem;
  border: 3px solid #6f5418;
  box-shadow:
    0 0 0 4px rgba(210, 170, 70, 0.25),
    inset 0 2px 4px rgba(255, 245, 210, 0.7),
    inset 0 -3px 6px rgba(0, 0, 0, 0.45),
    0 8px 18px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.5);
}

.cover-title {
  font-family: "Rye", "Playfair Display", serif;
  font-weight: 400;
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  margin: 4px 0 0;
  background: linear-gradient(180deg, #f6e6b6 0%, #d3aa4a 52%, #9a7423 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.6)) drop-shadow(0 -1px 0 rgba(255, 240, 200, 0.18));
}

.cover-sub {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  color: #e3c994;
  margin: 0;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.55));
}

.cover-motto {
  color: #b89a63;
  font-size: 0.9rem;
  font-style: italic;
  margin: 0 0 10px;
}

.cover-open-btn {
  margin-top: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(220, 178, 74, 0.4);
}

/* ====================================================================
   PARCHMENT PALETTE — applied to all in-page content (cards, fields,
   tables… inherit these custom properties; chrome stays leather)
   ==================================================================== */
.main-content,
#view-login {
  --bg-2: #f2e9d4;
  --surface: #ece0c6;
  --surface-2: #e3d6b8;
  --surface-3: #d8c8a4;
  --ink: #2b2013;
  --text: #2b2013;
  --text-muted: #574329;
  --text-subtle: #7a6442;
  --frost: #241a0e;
  --border: #bca981;
  --border-strong: #9d855c;
  --rule: #b09a72;
  --accent: #2f6275;
  --accent-strong: #1f4a59;
  --accent-soft: #356f83;
  color: var(--ink);
  /* native widgets (date picker icon + popups) render light to match the page */
  color-scheme: light;
}

/* make the date-picker calendar icon clearly visible (ink/brass) on parchment */
.main-content input[type="date"]::-webkit-calendar-picker-indicator,
.main-content input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: 1;
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  filter: sepia(1) saturate(2.2) hue-rotate(-12deg) brightness(0.55);
}

.main-content input[type="date"]::-webkit-calendar-picker-indicator:hover,
.main-content input[type="time"]::-webkit-calendar-picker-indicator:hover {
  background: rgba(150, 120, 70, 0.18);
}

/* Hide the page area until logged in (login shows as the title page) */
body:not(.is-authed) .main-content { display: none; }

/* ---- The open ledger page ---- */
.main-content {
  position: relative;
  width: min(1040px, calc(100% - 36px));
  perspective: 1600px;
  padding: 30px 40px 132px 58px;
  border-radius: 2px;
  background:
    linear-gradient(90deg, transparent 50px, rgba(150, 45, 35, 0.28) 50px 51px, transparent 51px),
    repeating-linear-gradient(180deg, transparent 0 31px, rgba(90, 66, 32, 0.10) 31px 32px),
    radial-gradient(120% 80% at 28% 6%, rgba(255, 250, 236, 0.55), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.05'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #ece0c6 0%, #e1d4b5 100%);
  background-blend-mode: normal, normal, soft-light, overlay, normal;
  box-shadow:
    0 0 0 1px rgba(60, 42, 22, 0.5),
    0 26px 60px rgba(0, 0, 0, 0.6),
    inset 0 0 70px rgba(120, 90, 50, 0.22);
}

/* binding gutter shadow on the left */
.main-content::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(70, 48, 24, 0.5), transparent);
}

/* page footer flourish */
.main-content::after {
  content: "❄  Sterling Ice Co.  ·  Registre de la Compagnie  ❄";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 64px;
  text-align: center;
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  color: rgba(108, 87, 58, 0.65);
}

/* ---- Content components re-tuned for parchment ---- */
.main-content .card {
  background:
    linear-gradient(180deg, rgba(255, 252, 242, 0.6), rgba(214, 197, 162, 0.3)),
    var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 2px 7px rgba(70, 50, 25, 0.18), inset 0 0 0 1px rgba(255, 250, 235, 0.4);
}

.main-content .card-panel::after {
  border-color: rgba(150, 120, 70, 0.45);
}

.main-content .card-stat strong,
.main-content .card-stat .stat-value,
.main-content h1,
.main-content h2,
.main-content h3,
.main-content .order-total-row strong {
  color: var(--ink);
}

.main-content .field-label input,
.main-content .field-label select,
.main-content .field-label textarea {
  /* background-COLOR only, so the select arrow's no-repeat/position survive */
  background-color: var(--bg-2);
  color: var(--ink);
  box-shadow: inset 0 1px 3px rgba(80, 55, 25, 0.2);
}

.main-content .field-label select {
  background-color: var(--bg-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236c573a' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
  padding-right: 36px;
}

.main-content .table th,
.main-content .table td {
  border-bottom: 1px solid rgba(150, 120, 70, 0.3);
}

.main-content .table th {
  border-bottom: 2px solid var(--rule);
}

.main-content .table tbody tr:hover {
  background: rgba(150, 45, 35, 0.06);
}

.main-content .order-total-edit input {
  background: var(--bg-2);
  color: var(--ink);
}

/* badges with ink-on-parchment contrast */
.main-content .badge-info { background: rgba(47, 98, 117, 0.16); color: #1f4a59; }
.main-content .badge-success { background: rgba(74, 107, 60, 0.18); color: #3a5a2a; }
.main-content .badge-warning { background: rgba(154, 107, 31, 0.18); color: #7a5316; }
.main-content .badge-danger { background: rgba(140, 47, 36, 0.16); color: #8c2f24; }

/* grade rows */
.main-content .grade-row { background: rgba(150, 120, 70, 0.08); }
.main-content .grade-row-head strong { color: var(--ink); }

/* readable danger / ghost buttons on parchment (defaults are light for dark theme) */
.main-content .btn-danger {
  color: #962a20;
  border-color: rgba(140, 47, 36, 0.55);
}
.main-content .btn-danger:hover {
  background: rgba(140, 47, 36, 0.12);
  color: #7a221a;
}
.main-content .btn-ghost { color: var(--ink); }

/* archived orders: subtle dashed frame */
.main-content .order-card-archived {
  border-left-color: var(--text-subtle);
  border-style: dashed;
  opacity: 0.9;
}
.filter-archived-label { align-self: end; }

/* paid/finished orders: dim less, keep the recap legible */
.main-content .order-card-done { opacity: 0.92; }
.main-content .order-summary-done {
  color: #6a553a;
  text-decoration-color: rgba(106, 85, 58, 0.7);
}
.main-content .order-card .text-muted,
.main-content .order-card-meta,
.main-content .order-summary { color: var(--ink); }
.main-content .order-card-meta { color: var(--text-muted); }

/* ---- Login as the title page ---- */
#view-login .brand-panel,
#view-login .form-card.card,
#view-login .card {
  background:
    radial-gradient(120% 80% at 30% 8%, rgba(255, 250, 236, 0.6), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='p2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p2)' opacity='0.05'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #ece0c6, #e1d4b5);
  color: var(--ink);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.6), inset 0 0 60px rgba(120, 90, 50, 0.18);
}

#view-login .brand-mark {
  background: radial-gradient(circle at 36% 30%, #f6e2a6, #c89a3a 55%, #876618 100%);
  color: #3a2808;
  border: 2px solid #6f5418;
}

#view-login .eyebrow { color: #9a7423; }
#view-login h1 { color: var(--ink); }
#view-login .brand-tagline,
#view-login .text-muted,
#view-login .field-label { color: var(--text-muted); }

#view-login .field-label input {
  background: var(--bg-2);
  color: var(--ink);
  box-shadow: inset 0 1px 3px rgba(80, 55, 25, 0.2);
}

#view-login .brand-mountains path[fill-opacity] { fill-opacity: 0.5; }

/* ====================================================================
   CANDLE GLOW + section page-turn
   ==================================================================== */
.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(55% 38% at 50% 4%, rgba(236, 188, 104, 0.14), transparent 60%);
}

@keyframes page-turn {
  0% { opacity: 0; transform: translateX(24px) rotateY(11deg); }
  100% { opacity: 1; transform: none; }
}

.view-active {
  transform-origin: left center;
  animation: page-turn 0.45s ease both;
}

/* ====================================================================
   Bottom nav as leather bookmark tabs
   ==================================================================== */
.nav-item {
  position: relative;
  border-radius: 10px 10px 5px 5px;
}

.nav-item::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 3px;
  border-radius: 2px;
  background: rgba(200, 161, 60, 0.45);
}

.nav-item-active {
  transform: translateY(-3px);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.4);
}

.nav-item-active::before { background: #f0e4c8; }

@media (max-width: 720px) {
  .book { width: min(360px, 88vw); }
  .main-content {
    width: calc(100% - 16px);
    padding: 22px 16px 120px 40px;
  }
  .main-content::after { font-size: 0.74rem; }
}
