/*
 * Adapts the original stylesheet to the rebuilt markup.
 *
 * style.css is linked unchanged, so anything the React version does
 * differently is reconciled here rather than by editing it. Kept short on
 * purpose: every rule below is a place the new markup differs from the Angular
 * template, and the list should shrink, not grow.
 */

/*
 * The blocks proof was a <canvas> the browser drew; it is now a PNG the server
 * renders, so the sizing rule has to reach an <img> too.
 *
 * style.css only ever set the 100px fallback — canvas.js then overwrote the
 * width with `pixelWidth * 2` (or * 1.4 below 768px) so the proof took its size
 * from how many columns the design actually uses. page.tsx passes that count in
 * as --columns; the arithmetic is the original's.
 */
#proof-canvas img {
  width: calc(var(--columns, 50) * 2px);
  margin-top: 100px;
}

@media (max-width: 768px) {
  #proof-canvas img {
    width: calc(var(--columns, 50) * 1.4px);
  }
}

/* The silhouette carried width/height attributes in the source SVG; inlined as
   JSX they would win over the 420px the stylesheet asks for. */
#proof-shirt {
  width: 420px;
  height: 420px;
}

/* The shirt selection sat inside a form the quote directive owned. */
.shirt-selection {
  margin-bottom: 12px;
}

/*
 * style.css asks for `min-height: 50%` on .editor and .designer — two bands,
 * each half the viewport. A percentage height resolves only against an
 * ancestor with a *definite* height, and nothing in the original set one, so
 * the rule never applied and both bands collapsed to their content.
 *
 * Saying it in viewport units instead needs no ancestor to cooperate, and is
 * what the 50% meant. .designer.done keeps its own 240px minimum, so the band
 * still shrinks once a design is chosen.
 */
.editor,
.editor .table,
.designer:not(.done),
.designer:not(.done) .table {
  min-height: 50vh;
}

/*
 * The two switch rows in the editor: the snippets to start from, and the
 * spacing to print them at.
 *
 * Both borrow the style switcher's voice — `>>` prefixes, the live one in the
 * theme's keyword colour, everything else quiet — so they read as part of the
 * page rather than as controls bolted onto it.
 */
.switch {
  /* style.css lines the editor column up by right-floating each block inside a
     700px cap (see the `.explanation, #step1-button, h1, #preview, #source`
     rule); without the same treatment this sits flush against the far edge. */
  width: 100%;
  max-width: 700px;
  float: right;
  margin: 18px 0 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
  /* Same face as `>> continue with this design` and `>> restart`, which
     style.css sets on .editor button and #step1-button. */
  font-family: "Source Code Pro", monospace;
  font-size: 13px;
  font-weight: 600;
}

.switch .label {
  opacity: 0.45;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  font-weight: 400;
  font-size: 12px;
}

.switch button {
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-transform: lowercase;
  cursor: pointer;
}

.switch button.silent {
  opacity: 0.45;
}

.switch button:hover {
  opacity: 1;
}

/*
 * The block preview answers the spacing switch too.
 *
 * Without this it shows lines of code with their leading while the proof below
 * it shows the dense mosaic — two different shirts on one screen.
 *
 * BLOKK Neue paints every glyph as a filled rectangle, 8px tall at the 18px
 * style.css asks for, and the leading is whatever the line box adds on top of
 * it. The print states the same thing as a ratio — a 50-unit block sitting on a
 * 170-unit band — so matching the two is just line-height over block height:
 * 170/50 for spaced, and 1 for solid, where the bands butt together into one
 * slab. Horizontal pitch needs no help; `letter-spacing: -3px` already has the
 * blocks touching, and the print has no column margin either.
 */
#preview code {
  --blokk-block: 0.4444em;   /* the 8px rectangle, in ems of the 18px face */
}

#preview.spacing-lines code {
  line-height: calc(var(--blokk-block) * 3.4);
}

#preview.spacing-solid code {
  line-height: var(--blokk-block);
}

/*
 * The code box fills the band it sits in.
 *
 * style.css gives #source a 200px min-height and the original grew it from
 * there with elastic.js (public/vendor/elastic.js), which the rewrite dropped.
 * So a long snippet scrolled inside a 200px box two-thirds of the way up an
 * otherwise empty half-screen band: 880px of code in 200px of room, with 340px
 * of white space below it.
 *
 * Both halves of the fix are in the JSX, because both depend on measurements
 * CSS cannot take: how tall the code wants to be, and how much of the 50vh band
 * the heading and the snippet row have already spent -- that row wraps to two
 * lines at this width and three at a narrower one, so the offset is not a
 * constant. All that is left here is suppressing the scrollbar on a box that no
 * longer needs one.
 */
.editor #source {
  /* It is sized to the band, so anything longer scrolls inside it rather than
     pushing the proof off the bottom of the screen. */
  overflow-y: auto;
}

/*
 * The snippet row sits above the code box, so the store suggests something to
 * print before you have thought of anything yourself. Six of them do not fit
 * one 700px line, hence the wrap and the tighter row gap.
 */
.snippets {
  flex-wrap: wrap;
  row-gap: 6px;
  margin: 4px 0 14px;
}

.density {
  margin: 18px 0 0;
}

/*
 * Variant C: the examples list in the editor's right column.
 *
 * The designer band puts the theme switcher in exactly this position, so the
 * list borrows #styleswitcher's metrics — italic, the same padding, the same
 * bold-when-current — and the two bands read as one column of things to choose
 * rather than two unrelated controls.
 */
#snippetpicker {
  font-style: italic;
}

#snippetpicker ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

#snippetpicker li {
  box-sizing: border-box;
  padding: 8px 20px;
  font-size: 16px;
  font-weight: 400;
}

#snippetpicker li.current {
  font-weight: 700;
}

/*
 * (2) Line the examples up with the themes.
 *
 * The editor band is `row editor` and the designer band is plain `designer` —
 * an asymmetry inherited from the original, where it never showed because the
 * editor's right-hand column was empty. A Bootstrap row pulls itself 15px wider
 * on each side, so its thirds land in different places: the editor's sidebar
 * started 5px right of the designer's and ran 10px wider, and the examples came
 * out 20px right of the themes.
 *
 * Cancelling the row's margins makes the two bands the same grid, and from
 * there the two lists can be positioned identically — so they stay aligned at
 * every width rather than at one.
 */
.editor.row {
  margin-left: 0;
  margin-right: 0;
}

/*
 * #styleswitcher is absolutely positioned and so escapes its column's 15px
 * padding. The examples list has to escape it the same way or it sits 15px
 * inboard of the themes it is meant to line up with.
 */
.editor .sidebar {
  position: relative;
}

#snippetpicker {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
}

/*
 * Below 768px the theme list turns into the off-canvas drawer behind the
 * `colors` button, and the columns stack. A second drawer would be one too
 * many, so the examples simply become a list under the code box — in flow,
 * full width, sharing the stacked column's own left edge, which is the same
 * edge everything else in the band uses at that size.
 */
@media (max-width: 768px) {
  #snippetpicker {
    position: static;
    width: auto;
  }

  #snippetpicker li {
    padding-left: 0;
    padding-right: 0;
  }
}

/*
 * (4) The buy button was falling back to the browser's own chrome — a 1.875px
 * outset border on #efefef in Source Sans Pro — because the original's button
 * rules are all keyed to ids and classes this one does not have (#finish,
 * #step1-button, .editor button). It is the last control in the flow and it
 * looked like the only thing on the page nobody had styled.
 *
 * Same voice as `>> continue with this design` and `>> restart`: no chrome,
 * the code face, the theme's keyword colour, and the nudge on hover that every
 * other `>>` control has.
 */
.quote button {
  border: 0;
  outline: none;
  /* It carries the theme's background now, so it needs the shape of a chip —
     matched to the size and fit buttons it sits under, which style.css gives
     8px corners. */
  padding: 13px 18px;
  border-radius: 8px;
  font-family: "Source Code Pro", monospace;
  font-size: 14px;
  font-weight: 600;
  text-transform: lowercase;
  cursor: pointer;
  transition: filter 120ms ease-in-out;
}

.quote button:hover:not(:disabled) {
  filter: brightness(1.12);
}

.quote button:disabled {
  opacity: 0.3;
  cursor: default;
}

/*
 * The destination row.
 *
 * `.quote` was a plain block of inline children, so "ships to", the country
 * menu and the buy button ran together with no space between them at all —
 * measured zero on both sides of the select. And the select was the one
 * control on the page still wearing the browser's own clothes: a 1px #767676
 * box 43px wide, sitting under fit and size buttons that style.css gives 8px
 * corners on #f5f6f7.
 *
 * Laying the row out with a gap and dressing the select like its neighbours
 * makes the last step of the purchase look like the rest of the page. The
 * chevron is drawn here because stripping `appearance` takes the native one
 * away with the rest of the chrome.
 */
.quote {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

#country {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 8px;
  background-color: #f5f6f7;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23454545' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding: 13px 36px 13px 16px;
  font: inherit;
  color: #454545;
  cursor: pointer;
  transition: background-color 200ms ease-in-out;
}

#country:hover,
#country:focus {
  background-color: #eceef0;
  outline: none;
}

/*
 * The proof has to count towards the height of the page.
 *
 * style.css positions #proof absolutely — `right: -95px; top: -14px` — so the
 * shirt and its caption take up no room in the flow at all. The original got
 * away with that because the form column beside it was long: another-shirt
 * button, warnings, a full-width quote button, terms. This one is short, so the
 * proof overflowed the row it sits in: the body came out 640px tall in a 714px
 * window, which is the white band along the bottom, and the caption explaining
 * the shirt colour was below the fold entirely — 93px of copy nobody could see.
 *
 * Reserving the proof's own height (500px plus its 10px of padding, less the
 * 14px it is pulled up by) lets the page contain what is drawn on it. Under
 * 768px style.css puts #proof back in the flow, where it measures itself.
 */
@media (min-width: 769px) {
  .row.forms {
    min-height: 520px;
  }
}
