/* Holloway - The Barham
   Ground rules for this design:
   - The viewer bay is a true neutral (R=G=B) 18% grey, because that is the surface
     a colourist or a fabric buyer judges colour against. Cream and white both lie.
   - Everything else stays out of the way of the textile.                            */

:root {
  --ink:        #171614;
  --ink-2:      #201E1B;
  --stage:      #767674;   /* neutral by construction: R = G = B */
  --stage-2:    #6A6A68;
  --paper:      #E7E3DA;
  --paper-ink:  #22201C;
  --rule:       #35322D;
  --meta:       #A09A8F;
  --mark:       #B4472F;   /* grease pencil, for rules and borders */
  --mark-text:  #DA7053;   /* the same pencil, lifted to clear 4.5:1 as text on ink */

  --display: "Libre Caslon Display", Georgia, serif;
  --body:    "IBM Plex Sans", system-ui, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, monospace;

  --gutter: clamp(1.25rem, 4vw, 3.5rem);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font: 300 16px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-weight: 400; margin: 0; }

button { font: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--mark-text);
  outline-offset: 3px;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 2rem;
  padding: 1.5rem var(--gutter);
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font-family: var(--display);
  font-size: 1.5rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper);
  text-decoration: none;
}

.masthead nav {
  display: flex;
  gap: 1.75rem;
  margin-left: auto;
}

.masthead nav a,
.masthead-note {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--meta);
  text-decoration: none;
}

.masthead nav a:hover { color: var(--paper); }

.masthead-note { border-left: 1px solid var(--rule); padding-left: 2rem; }

/* ---------- layout ---------- */

.piece {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  gap: clamp(1.5rem, 3vw, 3rem);
  padding: var(--gutter);
  align-items: start;
}

/* The specification carries the h1, so it comes first in the document and the
   grid puts it back on the right. Reading order stays h1 then h2. */
.stage-col { grid-column: 1; grid-row: 1; }
.ticket    { grid-column: 2; grid-row: 1; }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 0.7rem 1rem;
  z-index: 10;
}

.skip:focus { left: 0; }

/* ---------- the stage ---------- */

.stage {
  background:
    radial-gradient(115% 85% at 50% 18%, var(--stage) 0%, var(--stage-2) 62%, #5E5E5C 100%);
  border: 1px solid var(--rule);
  aspect-ratio: 4 / 3;
}

model-viewer {
  width: 100%;
  height: 100%;
  --progress-bar-color: var(--mark);
  --progress-mask: transparent;
}

.loading[hidden] { display: none; }

.loading {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  padding: 0.35rem 0.6rem;
  position: absolute;
  top: 1rem;
  left: 1rem;
}

.ar-btn {
  min-height: 44px;
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  padding: 0.7rem 1.15rem;
  background: var(--paper);
  color: var(--paper-ink);
  border: none;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ar-btn:hover { background: #fff; }

.stage-bar {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.85rem 0 0;
  border-bottom: 1px solid var(--rule);
}

.stage-note {
  margin: 0 0 0 auto;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--meta);
  text-align: right;
}

.ghost, .solid {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 44px;          /* thumb-sized, not pointer-sized */
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.6rem 1rem;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--meta);
}

.ghost:hover { color: var(--paper); border-color: var(--meta); }
.ghost[aria-pressed="true"] { color: var(--mark-text); border-color: var(--mark-text); }

.solid {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--paper-ink);
}

.solid:hover { background: #fff; }

/* ---------- dimension overlay ---------- */

#dim-lines { position: absolute; inset: 0; pointer-events: none; display: none; }
.dim-line { stroke: var(--paper); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.9; }

.dim { display: none; }

.stage[data-dims="on"] #dim-lines,
.stage[data-dims="on"] .dim { display: block; }

.dim.dot {
  width: 5px; height: 5px; padding: 0; border-radius: 50%;
  background: var(--paper); border: none;
}

.dim.label {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 0.2rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  transform: translate(-50%, -50%);
}

/* ---------- memo sample rail ---------- */

.rail-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.75rem 0 0.9rem;
}

.rail-head h2 {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.rail-head p {
  margin: 0 0 0 auto;
  font-size: 0.82rem;
  color: var(--meta);
}

.rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
}

/* a memo sample: the card a mill actually staples a cutting to */
.card {
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--ink-2);
  color: var(--paper);
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease;
}

.card:hover { transform: translateY(-2px); border-color: var(--meta); }

.card[aria-checked="true"] {
  border-color: var(--mark);
  transform: translateY(-2px);
}

.card .cutting {
  display: block;
  height: 88px;
  background-size: 320%;
  background-position: center;
  border-bottom: 1px solid var(--rule);
}

.card .tag {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem 0.6rem;
}

.card .nm { font-size: 0.86rem; }

.card .cd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.63rem;
  color: var(--meta);
}

.card[aria-checked="true"] .cd { color: var(--mark-text); }

/* the punched hole a swatch ring goes through */
.card .cutting::after {
  content: "";
  position: absolute;
  top: 8px; left: 8px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

/* ---------- specification ticket ---------- */

.ticket {
  background: var(--paper);
  color: var(--paper-ink);
  padding: clamp(1.5rem, 2.4vw, 2.25rem);
  position: sticky;
  top: var(--gutter);
}

.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #6B655B;
}

.ticket h1 {
  font-family: var(--display);
  font-size: clamp(2.4rem, 4.4vw, 3.4rem);
  line-height: 1;
  margin: 0.6rem 0 0.5rem;
}

.lede {
  margin: 0 0 1.6rem;
  font-size: 0.93rem;
  color: #4A453D;
  max-width: 34ch;
}

.spec { margin: 0; border-top: 1px solid rgba(34, 32, 28, 0.22); }

.spec .row {
  display: flex;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(34, 32, 28, 0.12);
}

.spec dt {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6B655B;
  flex: 0 0 8.5rem;
}

.spec dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.spec dd.restamp { animation: restamp 260ms ease; }

@keyframes restamp {
  0%   { opacity: 0; transform: translateY(-3px); }
  100% { opacity: 1; transform: none; }
}

.mill-note {
  margin: 1.15rem 0 1.75rem;
  padding-left: 0.85rem;
  border-left: 2px solid var(--mark);
  font-size: 0.86rem;
  color: #4A453D;
}

.ticket-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.ticket .ghost { color: #4A453D; border-color: rgba(34, 32, 28, 0.3); }
.ticket .ghost:hover { color: var(--paper-ink); border-color: var(--paper-ink); }

.trade {
  margin: 1.4rem 0 0;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: #6B655B;
}

/* ---------- loom section ---------- */

.weave {
  padding: clamp(2.5rem, 6vw, 5rem) var(--gutter);
  border-top: 1px solid var(--rule);
}

.weave h2 {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--meta);
  margin-bottom: 1.5rem;
}

.weave-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
}

.macro img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  border: 1px solid var(--rule);
}

.macro h3 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.15rem;
  margin: 0.75rem 0 0.3rem;
}

.macro p { margin: 0; font-size: 0.84rem; color: var(--meta); }

.macro .struct {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mark-text);
}

/* ---------- foot ---------- */

.foot {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.5rem var(--gutter) 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--meta);
}

.foot a { color: var(--meta); margin-left: auto; }

/* ---------- narrow ---------- */

@media (max-width: 900px) {
  .piece { grid-template-columns: 1fr; }
  /* one column: show the piece before its paperwork, without moving the h1 */
  .stage-col { grid-column: 1; grid-row: 1; order: -1; }
  .ticket    { grid-column: 1; grid-row: auto; }
  .ticket { position: static; }
  .masthead { flex-wrap: wrap; gap: 1rem; }
  .masthead nav { margin-left: 0; width: 100%; gap: 1.25rem; }
  .masthead-note { border-left: 0; padding-left: 0; }
  .stage { aspect-ratio: 1 / 1; }
  .stage-bar { flex-direction: column; gap: 0.6rem; align-items: flex-start; }
  .stage-note { margin-left: 0; text-align: left; }
  .rail-head { flex-direction: column; gap: 0.35rem; }
  .rail-head p { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
