/* ============================================================
   TYPE SIZES — the only sizes you need to touch
   ============================================================ */
:root{
  --type-big:clamp(24.4px,2.34vw,37.8px);   /* word size, desktop    */
  --type-big-m:clamp(29.8px,3.6vw,40px);    /* word size, compact    */
  --type-small:clamp(16px,1.2vw,18px);      /* name/contact, desktop */
  --type-small-m:14px;                      /* name/contact, compact */
  --grid-pad-y:9vh;                         /* desktop margins       */
  --grid-pad-x:7vw;
  --meta-inset-y:7vh;                       /* corner text inset     */
  --meta-inset-x:7vw;
}

@font-face{font-family:"Brown";src:url(assets/brown-regular.woff?v=1) format("woff");
  font-weight:400;font-style:normal;font-display:block}

*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100vh;height:100dvh;background:#000;overflow:hidden;overscroll-behavior:none;overscroll-behavior-x:none;-webkit-touch-callout:none}
body{touch-action:none;font-family:"Brown",system-ui,sans-serif;font-weight:400;letter-spacing:-.03em;
  -webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}

/* Height comes from dvh, not vh: on a phone, vh is the viewport with the
   browser's own bars hidden, which is taller than what you can actually
   see while they are showing. The renderer also writes this size in px
   from JS, which is what finally guarantees the canvas is displayed at
   exactly the size it was drawn at. */
canvas#gl{position:fixed;inset:0;background:#000;width:100vw;height:100vh;height:100dvh;z-index:1;display:block;pointer-events:none}

/* The words are laid out by the browser and painted by WebGL, so the DOM copy
   is hidden — but only once WebGL is actually painting. It is the fallback as
   well as the layout and the text for screen readers, so it is visible by
   default and hidden on success rather than the other way round: no script,
   no WebGL, a failed start or a lost context all leave a readable page
   instead of a black one. `booting` covers the moment before the first frame. */
.grid{position:fixed;inset:0;height:100vh;height:100dvh;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));
  grid-template-rows:repeat(5,1fr);padding:var(--grid-pad-y) var(--grid-pad-x);
  font-size:var(--type-big);color:#fff;z-index:2;pointer-events:none}
.w{align-self:center;white-space:nowrap;position:relative;color:#fff}
/* `booting` hides the type for the moment before the first WebGL frame, but it
   lets go on its own, in CSS, rather than waiting to be told to by script.
   That matters: if the script never runs at all — blocked by an embed, a
   sandbox, a content policy, a browser that will not parse it — the type still
   appears, and the page is readable instead of blank. `gl` then holds it
   hidden for as long as WebGL is genuinely painting, and overrides this. */
html.booting .w{
  color:transparent;-webkit-text-fill-color:transparent;
  animation:showType 0s linear 1.4s forwards}
@keyframes showType{to{color:#fff;-webkit-text-fill-color:#fff}}
html.gl .w{
  color:transparent!important;-webkit-text-fill-color:transparent!important;
  -webkit-text-stroke:0!important;text-shadow:none!important;
  animation:none!important}
.c1{grid-column:1;justify-self:start}
.c2{grid-column:2;justify-self:center}
.c3{grid-column:3;justify-self:center}
.c4{grid-column:4;justify-self:end}
.mid{grid-column:2 / span 2;justify-self:center}
.r1{grid-row:1}.r2{grid-row:2}.r3{grid-row:3}.r4{grid-row:4}.r5{grid-row:5}

/* The two centre-column words sit in rows 2 and 4 of a five-row grid, so left
   alone they fall 20% of the page apart from the rows above and below them but
   40% apart from each other — row 3 has nothing in the middle. Pulling them
   together by a third of a row each puts the four things in this column at
   even intervals down the page. A third, not a quarter: the gap to close is a
   whole row, and both ends move. */
@media (orientation:landscape) and (min-width:1101px){
  .mid.r2{transform:translateY(calc((100vh - 2*var(--grid-pad-y))/15))}
  .mid.r4{transform:translateY(calc((100vh - 2*var(--grid-pad-y))/-15))}
}

.meta{position:fixed;inset:0;z-index:5;pointer-events:none;
  font-family:"Brown",system-ui,sans-serif;font-size:var(--type-small);
  font-weight:400;line-height:1.4;letter-spacing:.01em;color:#929292}
.meta span,.meta a{position:absolute;white-space:nowrap;
  color:#929292!important;-webkit-text-fill-color:#929292!important;
  text-decoration:none;pointer-events:auto}
.meta-name{left:var(--meta-inset-x);top:var(--meta-inset-y)}
.meta-role{right:var(--meta-inset-x);top:var(--meta-inset-y);text-align:right}
.meta-email{left:var(--meta-inset-x);bottom:var(--meta-inset-y)}
.meta-linkedin{right:var(--meta-inset-x);bottom:var(--meta-inset-y);text-align:right}
.meta a:hover{text-decoration:underline;text-underline-offset:4px}

/* ---- compact: two columns, and the first and last word rows are dropped.
        app.js rotates those words back in on every full black-white cycle. ---- */
@media (orientation:portrait),(max-width:1100px){
  .grid{grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:repeat(7,auto);
    align-content:space-between;height:100vh;height:100dvh;
    padding:max(8vw,env(safe-area-inset-top)) 8vw max(8vw,env(safe-area-inset-bottom));
    font-size:var(--type-big-m)}
  .c1,.c3{grid-column:1;justify-self:start}
  .c2,.c4{grid-column:2;justify-self:end}
  .mid{grid-column:1 / span 2}
  .w.m1,.w.m7{display:none}
  .mi1{grid-row:1}.m2{grid-row:2}.m3{grid-row:3}.m4{grid-row:4}
  .m5{grid-row:5}.m6{grid-row:6}.mi2{grid-row:7}

  .meta{font-size:var(--type-small-m)}
  .meta-name{left:8vw;top:max(8vw,env(safe-area-inset-top))}
  .meta-role{right:8vw;top:max(8vw,env(safe-area-inset-top))}
  .meta-email{left:8vw;bottom:max(8vw,env(safe-area-inset-bottom))}
  .meta-linkedin{right:8vw;bottom:max(8vw,env(safe-area-inset-bottom))}
}

/* Landscape on a phone needs its own vertical inset, and only that. The
   compact rules inset all four captions by 8vw, which is a share of the
   width — and in landscape the width is the long side, so vertically it put
   them 72px down a 414px-tall screen, sitting on the first and last word
   rows. Horizontally 8vw is exactly right: it is the grid's own padding, so
   the captions line up with the word columns rather than floating out past
   them. So the width keeps 8vw and the height gets 9vh of its own.
   env() is added on every side to clear a notch, which in landscape sits on
   the left or right rather than the top. */
@media (orientation:landscape) and (max-width:1100px){
  .meta-name,.meta-role{top:max(9vh,env(safe-area-inset-top))}
  .meta-email,.meta-linkedin{bottom:max(9vh,env(safe-area-inset-bottom))}
  .meta-name,.meta-email{left:max(8vw,env(safe-area-inset-left))}
  .meta-role,.meta-linkedin{right:max(8vw,env(safe-area-inset-right))}
}

/* A window shorter than this has no business being this wide, but it happens:
   drag a desktop window down to a letterbox and the rows stop fitting between
   the margins. The margins are a share of the width, the type is a share of
   the width, and neither knows the height has run out — so the rows spill past
   the padding and land on the captions. Below 340px everything that eats
   height gets measured against the height instead: the margins, the type, and
   the caption inset. Nothing above 340px is touched, which is every real
   phone in landscape and every sane desktop window. */
@media (max-height:340px){
  .grid{padding-top:max(5vh,env(safe-area-inset-top));
        padding-bottom:max(5vh,env(safe-area-inset-bottom));
        font-size:min(var(--type-big),5.6vh)}
  .meta{font-size:min(var(--type-small),4vh)}
  .meta-name,.meta-role{top:max(2.5vh,env(safe-area-inset-top))}
  .meta-email,.meta-linkedin{bottom:max(2.5vh,env(safe-area-inset-bottom))}
  /* the centre-column nudge is written against the normal padding, so it has
     to be restated against the one in force here */
  .mid.r2{transform:translateY(calc((100vh - 10vh)/15))}
  .mid.r4{transform:translateY(calc((100vh - 10vh)/-15))}
}
@media (max-height:340px) and (max-width:1100px){
  .grid{font-size:min(var(--type-big-m),5.6vh)}
  .meta{font-size:min(var(--type-small-m),4vh)}
}
