/* S-05 Logo: the construction of the real mark. One slider takes it from a thin
   centre-line over the full construction (grid, key lines, callouts) to the solid mark.
   JS only sets numbers (--sw10, --sw7, --o1..3, --osk, --fs, --hair); all drawing is CSS. */

@property --lg-bg { syntax: '<color>'; inherits: true; initial-value: #F4F1EA; }
@property --lg-fg { syntax: '<color>'; inherits: true; initial-value: #1F3563; }
@property --lg-red { syntax: '<color>'; inherits: true; initial-value: #B53A26; }

.lg {
  --lg-bg: var(--paper);
  --lg-fg: var(--ink);
  --lg-red: var(--red);
  --sw10: 10; --sw7: 7; --hair: .4; --fs: 3.2px;
  --o1: 0; --o2: 0; --o3: 0; --osk: 0; --ms: 1.16; /* no JS: the clean mark */
  container-type: inline-size;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  color: var(--lg-fg);
  background-color: var(--lg-bg);
  touch-action: pan-y;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: --lg-bg .6s var(--ease-io), --lg-fg .6s var(--ease-io), --lg-red .6s var(--ease-io);
}
.lg[data-variant="dark"] { --lg-bg: var(--ink); --lg-fg: var(--paper); --lg-red: #FF8F76; }
.lg[data-variant="mono"] { --lg-bg: #FFFFFF; --lg-fg: #0B0B0B; }

.lg__svg {
  position: absolute; inset: 0; display: block;
  width: 100%; height: 100%;
  transition: opacity .35s var(--ease);
}

/* ------------------------------------------------------------- the mark */
.lg__mark, .lg__skel { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.lg__mark, .lg__skel { transform: scale(var(--ms)); transform-origin: 60px 60px; }
.lg__mark { stroke: var(--lg-fg); }
.lg__w10 { stroke-width: var(--sw10); }
.lg__w7 { stroke-width: var(--sw7); }
/* the centre-line stays visible inside the strokes while they thicken */
.lg__skel { stroke: var(--lg-bg); opacity: var(--osk); }
.lg__s10, .lg__s7 { stroke-width: var(--hair); }

/* --------------------------------------------------- construction layers */
.lg__g { color: var(--lg-fg); }
.lg__g1 { opacity: var(--o1); }
.lg__g2 { opacity: var(--o2); }
.lg__g3 { opacity: var(--o3); pointer-events: none; }

.lg__g path, .lg__g rect, .lg__g circle {
  fill: none; stroke: currentColor; stroke-width: 1px; stroke-opacity: .5;
  vector-effect: non-scaling-stroke;
}
.lg__g .lg__hair { stroke-opacity: .15; }
.lg__g .lg__hair--tick { stroke-opacity: .4; }
.lg__g .lg__major { stroke-opacity: .36; }
.lg__g .lg__kl { stroke-opacity: .42; stroke-dasharray: 5 4; }
.lg__g .lg__kl--dd { stroke-dasharray: 14 4 2 4; stroke-opacity: .34; }
.lg__g .lg__kl--long { stroke-dasharray: 2 5; stroke-opacity: .5; }
.lg__g .lg__solid { stroke-opacity: .55; }
.lg__g .lg__ar, .lg__g .lg__dot { fill: currentColor; stroke: none; }
.lg__g .lg__hit { fill: transparent; stroke: none; pointer-events: none; }
.lg__g .lg__ref { stroke-dasharray: 3 3; stroke-opacity: .7; }
.lg__g .lg__arc { stroke-opacity: 1; stroke-width: 1.4px; }
.lg__dim path, .lg__co path { stroke-opacity: .8; }

.lg__tx {
  font: 500 var(--fs) var(--mono);
  letter-spacing: .05em;
  fill: currentColor;
  stroke: var(--lg-bg); stroke-width: .5em; stroke-linejoin: round;
  paint-order: stroke;
  pointer-events: none;
}

/* the active callout and the part of the drawing it measures */
.lg__co, .lg__t { transition: color .3s var(--ease); }
.lg__svg.is-live .lg__hit { pointer-events: all; }
.lg__svg.is-live .lg__co { pointer-events: auto; cursor: pointer; }
.lg .is-hot { color: var(--lg-red); }
.lg__g .is-hot, .lg__g .is-hot path, .lg__g .is-hot rect, .lg__g .is-hot circle { stroke-opacity: 1; }
.lg__g .lg__kl.is-hot { stroke-width: 1.5px; }

/* mono readout in the corner of the sheet */
.lg__val {
  position: absolute; right: 3.2cqi; bottom: 3cqi;
  padding: 4px 6px 3px;
  background: var(--lg-fg); color: var(--lg-bg);
  font: 500 10.5px/1 var(--mono); letter-spacing: .06em;
  transition: opacity .35s var(--ease);
  pointer-events: none;
}

/* ------------------------------------------------------ small sizes view */
.lg__small {
  position: absolute; inset: 0;
  display: grid; grid-template-rows: 1fr 1fr;
  opacity: 0; visibility: hidden;
  transition: opacity .45s var(--ease), visibility 0s .45s;
}
.lg[data-variant="small"] .lg__small { opacity: 1; visibility: visible; transition: opacity .45s var(--ease) .1s, visibility 0s; }
.lg[data-variant="small"] .lg__svg, .lg[data-variant="small"] .lg__val { opacity: 0; pointer-events: none; }

.lg__strip {
  --gl: rgba(31, 53, 99, .07);
  --bar: 52px;
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
  padding-top: var(--bar);
  background:
    linear-gradient(to right, var(--gl) 1px, transparent 1px) 50% 50% / 16px 16px,
    linear-gradient(to bottom, var(--gl) 1px, transparent 1px) 50% 50% / 16px 16px,
    var(--bg);
}
.lg__strip--light { --bg: var(--paper); --edge: rgba(31, 53, 99, .4); color: var(--ink); }
.lg__strip--dark { --bg: var(--ink); --edge: rgba(244, 241, 234, .4); --gl: rgba(244, 241, 234, .09); color: var(--paper); }

/* where the small sizes live: a browser tab (16 px) and a profile picture (32 px) */
.lg__bar {
  position: absolute; left: 0; right: 0; top: 0; height: var(--bar);
  display: flex; align-items: flex-end; gap: 10px; padding: 0 3.2cqi;
  border-bottom: 1px solid var(--edge);
  font: 500 12px/1 var(--mono); letter-spacing: .02em;
}
.lg__tab {
  display: inline-flex; align-items: center; gap: 9px;
  height: 36px; padding: 0 14px 0 11px; margin-bottom: -1px;
  border: 1px solid var(--edge); border-bottom-color: var(--bg); border-radius: 7px 7px 0 0;
  background: var(--bg);
  white-space: nowrap;
}
.lg__tab svg { display: block; flex: none; }
.lg__strip--dark .lg__bar { align-items: center; }
.lg__ava {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--edge);
}
.lg__ava svg { display: block; }
.lg__row {
  position: relative;
  display: flex; align-items: flex-end;
  gap: clamp(20px, 11cqi, 84px);
}
.lg__row::after {
  content: ""; position: absolute; left: -60cqi; right: -60cqi; bottom: 28px; height: 1px;
  background: currentColor; opacity: .38;
}
.lg__sz { display: flex; flex-direction: column; align-items: center; }
.lg__sz:nth-child(1) { --s: 16px; }
.lg__sz:nth-child(2) { --s: 24px; }
.lg__sz:nth-child(3) { --s: 32px; }
.lg__sz:nth-child(4) { --s: 64px; }
.lg__sz svg { display: block; flex: none; }
.lg__szl {
  position: relative; display: block; height: 28px; padding-top: 13px;
  font: 500 10.5px/1 var(--mono); font-style: normal; letter-spacing: .08em; text-transform: uppercase;
  white-space: nowrap;
}
.lg__szl::before {
  content: ""; position: absolute; top: 5px; left: 50%;
  width: var(--s); height: 5px; margin-left: calc(var(--s) / -2);
  background:
    linear-gradient(currentColor, currentColor) 0 50% / 100% 1px no-repeat,
    linear-gradient(currentColor, currentColor) 0 0 / 1px 100% no-repeat,
    linear-gradient(currentColor, currentColor) 100% 0 / 1px 100% no-repeat;
  opacity: .7;
}
.lg__scale {
  position: absolute; right: 3.2cqi; top: 0; height: var(--bar);
  display: flex; align-items: center;
  font: 500 10.5px/1 var(--mono); letter-spacing: .08em; opacity: .7;
}

/* -------------------------------------------------------------- controls */
.lg__ctl { display: grid; gap: 12px; container: lgctl / inline-size; }
.lg__slider {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center; gap: 0 12px;
  transition: opacity .3s var(--ease);
}
.lg__ctl.is-off .lg__slider { opacity: .35; pointer-events: none; }
.lg__end {
  min-height: 44px; padding: 0 2px;
  border: 0; background: none; cursor: pointer;
  font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink);
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 5px;
  transition: text-decoration-color .2s;
  white-space: nowrap;
}
.lg__end:hover { text-decoration-color: currentColor; }

.lg__range { position: relative; height: 44px; --v: 0; }
.lg__range::before, .lg__range::after { content: ""; position: absolute; left: 10px; pointer-events: none; }
.lg__range::before {
  right: 10px; top: 50%; height: 14px; margin-top: -7px;
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) 0 50% / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 10%) 0 50% / 100% 9px no-repeat,
    linear-gradient(var(--line-strong), var(--line-strong)) 100% 50% / 1px 9px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 50% / 1px 14px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 50% 50% / 1px 14px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 50% / 1px 14px no-repeat;
}
.lg__range::after {
  top: 50%; height: 2px; margin-top: -1px;
  width: calc((100% - 20px) * var(--v) / 100);
  background: var(--ink);
}
.lg__input {
  position: relative; z-index: 1;
  height: 44px; outline: none; cursor: ew-resize;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}
.lg__thumb {
  position: absolute; top: 6px; left: calc((100% - 20px) * var(--v) / 100);
  width: 20px; height: 32px; border-radius: 2px;
  background:
    linear-gradient(90deg, transparent 6px, var(--paper) 6px 7px, transparent 7px 9.5px, var(--paper) 9.5px 10.5px, transparent 10.5px 13px, var(--paper) 13px 14px, transparent 14px) 0 50% / 100% 14px no-repeat,
    var(--ink);
  box-shadow: 0 0 0 3px var(--sheet), 0 8px 16px -10px rgba(31, 53, 99, .8);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.lg__input:hover .lg__thumb, .lg__input.is-dragging .lg__thumb { transform: scaleY(1.1); }
.lg__input:focus-visible .lg__thumb { box-shadow: 0 0 0 3px var(--sheet), 0 0 0 5px var(--red); }

.lg__vars { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@container lgctl (min-width: 600px) {
  .lg__vars { display: flex; flex-wrap: wrap; }
}
.lg__v {
  flex: 1 1 auto; min-width: 0;
  display: inline-flex; align-items: center; justify-content: flex-start; gap: 10px;
  min-height: 44px; padding: 0 14px 0 7px;
  border: 1px solid var(--line-strong); border-radius: 2px;
  background: transparent; color: var(--ink); cursor: pointer;
  font: 500 14px/1.15 var(--font); text-align: left;
  transition: background-color .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
}
.lg__v:hover { background: var(--paper-2); }
.lg__v[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.lg__sw {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px;
  border: 1px solid var(--line-strong);
}
.lg__sw svg { width: 20px; height: 20px; }
.lg__sw--main { background: var(--paper); color: var(--ink); }
.lg__sw--dark { background: var(--ink); color: var(--paper); border-color: rgba(244, 241, 234, .5); }
.lg__sw--mono { background: #FFFFFF; color: #0B0B0B; }
.lg__sw--small { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 38px; padding-bottom: 3px; background: var(--paper); color: var(--ink); }
.lg__sw--small svg { flex: none; }
.lg__sw--small .s1 { width: 6px; height: 6px; }
.lg__sw--small .s2 { width: 10px; height: 10px; }
.lg__sw--small .s3 { width: 16px; height: 16px; }
.lg__v[aria-pressed="true"] .lg__sw { border-color: rgba(244, 241, 234, .55); }

@media (max-width: 600px) {
  .lg__slider { grid-template-columns: 1fr 1fr; gap: 0; }
  .lg__end--a { grid-area: 1 / 1; justify-self: start; }
  .lg__end--b { grid-area: 1 / 2; justify-self: end; }
  .lg__range { grid-area: 2 / 1 / 3 / 3; }
  .lg__end { min-height: 40px; }
  .lg__v { font-size: 13.5px; padding-right: 8px; gap: 8px; }
  .lg__row { gap: 9cqi; }
  .lg__strip { --bar: 44px; }
  .lg__ava { width: 38px; height: 38px; }
  .lg__ava svg { width: 26px; height: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .lg, .lg__svg, .lg__val, .lg__small, .lg__co, .lg__t, .lg__slider, .lg__v, .lg__end { transition: none !important; }
}
