/* ---------------------------------------------------------------
   Grout — Type Playground
   --------------------------------------------------------------- */

/* The interface is set in Grout too, so the whole embed reads as
   one piece rather than a browser form sitting on the artwork.
   p5 loads the font separately for the canvas; this is the copy the
   HTML uses. Same file, so the browser serves the second request
   from cache.

   If you add other weights, add a block for each and give them the
   same family name with a different font-weight. */
@font-face{
  font-family: "Grout";
  src: url("Grout-Regular.otf");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
/*
@font-face{
  font-family: "Grout";
  src: url("Grout-Bold.otf");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
*/

:root{
  --ink:      #111;
  --paper:    #fff;
  --line:     #d8d8d8;
  /* The typeface itself, with a serif fallback so a missing file
     degrades to something of the same species rather than jumping
     to a sans. Set --label-font back to the sans stack if you want
     the little uppercase labels to stay neutral. */
  --ui-font:    "Grout", Georgia, "Times New Roman", serif;
  --label-font: "Grout", Georgia, "Times New Roman", serif;
  --sans:       "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* --- TYPE SIZES -------------------------------------------------
     --read-size is the text field, set to match the body copy on
     your own site (measured at ~21px). Drop it to 16px if the bar
     starts to feel heavier than the artwork.
     ---------------------------------------------------------------- */
  --read-size: 20px;   /* the text field */
  --read-line: 29px;   /* its line height — keep ~1.45x --read-size */
  --ui-size:   15px;   /* dropdowns */
  --btn-size:  12px;   /* buttons */
  --label-size:11px;   /* the little uppercase labels */

  --gap:      10px;
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  padding: 0;
  background: transparent;   /* lets the Cargo page colour show through */
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: var(--ui-size);
  -webkit-font-smoothing: antialiased;
}

/* The artwork runs the full width of whatever column it sits in.
   The controls stay a readable width, centred above it. */
#app{
  max-width: 100%;
  margin: 0;
  padding: 0 0 4px;
}

/* ----- controls ----- */

/* The control bar lines up with the edges of the artwork. */
#controls{ max-width: none; margin: 0 0 var(--gap); }

.row{
  display: flex;
  gap: var(--gap);
  flex-wrap: wrap;
  margin-top: var(--gap);
}

.field{ display: block; }
.field.small{ flex: 1 1 130px; min-width: 120px; }

.field > span{
  display: block;
  margin-bottom: 5px;
  font-family: var(--label-font);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: var(--label-size);
  opacity: 0.6;
}

.field b{ font-weight: 400; opacity: 1; }

textarea, select{
  width: 100%;
  font-family: var(--ui-font);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
}
textarea{
  font-size: var(--read-size);
  line-height: var(--read-line);
  padding: 10px 12px;
  /* grows to its content, between three and eight whole lines */
  height: calc(var(--read-line) * 3 + 22px);
  min-height: calc(var(--read-line) * 3 + 22px);
  max-height: calc(var(--read-line) * 8 + 22px);
  overflow-y: auto;
  resize: vertical;
}
select{
  font-size: var(--ui-size);
  padding: 7px 9px;
  height: 38px;
}
textarea:focus, select:focus{ border-color: var(--ink); }

input[type=range]{
  width: 100%;
  margin: 10px 0 0;
  accent-color: var(--ink);
}

.buttons{
  display: flex;
  gap: 6px;
  flex: 3 1 420px;
  align-self: flex-end;
}

/* --- weight switch -------------------------------------------------
   A segmented control rather than a dropdown: four static weights
   are worth showing all at once in a specimen. */
.field.weights{ flex: 1 1 300px; min-width: 260px; }

.segmented{ display: flex; }

.segmented button{
  flex: 1 1 0;
  margin-left: -1px;            /* shared borders, no double rule */
  white-space: nowrap;
}
.segmented button:first-child{ margin-left: 0; }

.segmented button.is-on{
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  position: relative;           /* keeps its border above the neighbours */
  z-index: 1;
}

.segmented button:disabled{
  opacity: 0.3;
  cursor: not-allowed;
}
.segmented button:disabled:hover{
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

button{
  flex: 1 1 auto;
  font-family: var(--label-font);
  font-size: var(--btn-size);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 12px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
button:hover{ background: var(--ink); color: var(--paper); border-color: var(--ink); }
button:active{ transform: translateY(1px); }

/* ----- canvas ----- */

/* Let p5 decide the canvas size — it fits the artwork to the space
   available. Forcing width:100% here would override that and clip
   the bottom of the composition. */
#canvas-holder{
  display: flex;
  justify-content: center;
  line-height: 0;
}
#canvas-holder canvas{
  display: block;
  max-width: 100%;
  height: auto;
}

#hint{
  max-width: none;
  margin: 8px 0 0;
  font-family: var(--label-font);
  font-size: var(--label-size);
  letter-spacing: 0.02em;
  opacity: 0.45;
}

@media (max-width: 760px){
  .field.weights{ flex: 1 1 100%; }
  .buttons{ flex: 1 1 100%; flex-wrap: wrap; }
  button{ flex: 1 1 45%; }
}
@media (max-width: 520px){
  .field.small{ flex: 1 1 100%; }
}
