/* Beam: refined monochrome.

   The look is a darkroom, not a dashboard. Black, one warm white, and the record red as
   the only colour in the building. Depth comes from layered greys, a fine grain and long
   soft shadows rather than from hue. Type does the talking: a display serif for the few
   words that matter against a mono for everything factual.

   Carried over from the Mac app so the two feel like one product, then tightened. */

@layer tokens, base, layout, components, motion;

@layer tokens {
  :root {
    /* Greys are warm by a hair. A true neutral reads as cheap on an OLED phone. */
    --black:#08080a;
    --bg:#0a0a0c;
    --raise:#111113;
    --raise-2:#161618;
    --line:#212125;
    --line-hi:#34343a;
    --ink:#f6f5f3;
    --ink-2:#a8a7a4;
    --ink-3:#6c6b69;
    --rec:#ec4444;

    --display:'Instrument Serif', Georgia, serif;
    --sans:'Hanken Grotesk', -apple-system, system-ui, sans-serif;
    --mono:'IBM Plex Mono', ui-monospace, monospace;

    /* One shadow recipe, three depths. Long, soft and nearly black: a screen recorder
       should feel like it is lit from a window, not ringed in grey. */
    --lift-1:0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.28);
    --lift-2:0 2px 4px rgba(0,0,0,.45), 0 12px 32px rgba(0,0,0,.4);
    --lift-3:0 8px 16px rgba(0,0,0,.5), 0 32px 64px rgba(0,0,0,.55);

    --r-sm:8px; --r-md:12px; --r-lg:18px; --r-pill:999px;
    --ease:cubic-bezier(.2,.7,.3,1);
    --gutter:clamp(16px, 4vw, 40px);
  }
}

@layer base {
  *, *::before, *::after { box-sizing:border-box; }
  html { -webkit-text-size-adjust:100%; }
  body {
    margin:0; min-height:100dvh; background:var(--bg); color:var(--ink);
    font:400 15px/1.55 var(--sans); letter-spacing:-.005em;
    -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
  }
  /* A whisper of grain over everything. Flat black on a phone screen looks like a dead
     pixel field; grain gives it a surface. */
  body::before {
    content:''; position:fixed; inset:0; z-index:9999; pointer-events:none; opacity:.028;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  }
  /* Any rule that sets display beats the browser's own [hidden] rule, so a class with
     display:grid quietly stays on screen after JS sets .hidden = true. That kept the
     "Opening" veil over a playable video. One rule, once, for every element. */
  [hidden] { display:none !important; }
  a { color:inherit; text-decoration:none; }
  :focus-visible { outline:2px solid var(--ink); outline-offset:3px; border-radius:4px; }
  ::selection { background:var(--ink); color:var(--black); }
  img, video { display:block; max-width:100%; }
}

@layer layout {
  .wrap { max-width:1080px; margin:0 auto; padding:clamp(18px,3vw,34px) var(--gutter) 96px; }

  /* The masthead: mark, then a hairline that runs the width, then the page. */
  .bar { display:flex; align-items:center; gap:14px; padding-bottom:18px; margin-bottom:26px;
         border-bottom:1px solid var(--line); }
  .bar .right { margin-left:auto; display:flex; align-items:center; gap:10px; }
  .mark { display:flex; align-items:center; gap:10px; font:600 15px/1 var(--sans); letter-spacing:.01em; }
  .mark svg { overflow:visible; }

  /* Section labels are small, mono and quiet: they are signposts, not headlines. */
  .eyebrow { font:500 10.5px/1 var(--mono); letter-spacing:.14em; text-transform:uppercase;
             color:var(--ink-3); margin:34px 0 14px; display:flex; align-items:center; gap:12px; }
  .eyebrow::after { content:''; flex:1; height:1px; background:var(--line); }
}

@layer components {
  .mono { font-family:var(--mono); font-size:11.5px; letter-spacing:-.01em; }
  .muted { color:var(--ink-2); }
  .dim { color:var(--ink-3); }

  .card { background:var(--raise); border:1px solid var(--line); border-radius:var(--r-md); padding:18px; }
  .row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

  button, .btn {
    font:600 12.5px/1 var(--sans); letter-spacing:.005em; color:var(--ink); cursor:pointer;
    background:var(--raise); border:1px solid var(--line); border-radius:var(--r-sm);
    padding:9px 14px; transition:border-color .16s var(--ease), background .16s var(--ease),
      transform .16s var(--ease), color .16s var(--ease);
  }
  button:hover:not(:disabled), .btn:hover { border-color:var(--line-hi); background:var(--raise-2); }
  button:active:not(:disabled) { transform:translateY(1px); }
  button:disabled { opacity:.32; cursor:default; }

  /* The one loud control on any page. White on black, and it shifts under the cursor. */
  .primary {
    background:var(--ink); color:var(--black); border:0; border-radius:var(--r-pill);
    padding:11px 20px; font-weight:700; box-shadow:var(--lift-1);
  }
  .primary:hover { background:#fff; box-shadow:var(--lift-2); transform:translateY(-1px); }
  .primary .dot { background:var(--rec); }

  .icon { width:32px; height:32px; padding:0; border-radius:var(--r-pill); background:transparent;
          border:1px solid transparent; color:var(--ink-3); display:inline-flex;
          align-items:center; justify-content:center; }
  .icon:hover { color:var(--ink); background:var(--raise-2); border-color:var(--line); }

  .dot { width:8px; height:8px; border-radius:50%; background:var(--rec); display:inline-block; }
  .live .dot { animation:beat 1.4s infinite; }
  .paused .dot { animation:none; opacity:.45; }
  .timer { font:500 26px/1 var(--mono); font-variant-numeric:tabular-nums; letter-spacing:-.02em; }

  label.check { display:inline-flex; align-items:center; gap:8px; font-size:13.5px; color:var(--ink-2); }
  label.check:hover { color:var(--ink); }
  input[type=checkbox] { accent-color:var(--ink); width:15px; height:15px; }
  select, input[type=text], input:not([type]) {
    font:inherit; font-size:13px; color:var(--ink); background:var(--raise-2);
    border:1px solid var(--line); border-radius:var(--r-sm); padding:9px 11px;
  }
  select:hover, input:hover { border-color:var(--line-hi); }

  .badge { font:500 9.5px/1 var(--mono); letter-spacing:.1em; text-transform:uppercase;
           color:var(--ink-3); border:1px solid var(--line); border-radius:var(--r-sm); padding:5px 7px; }

  .notice { border:1px solid var(--line); background:var(--raise); border-radius:var(--r-md);
            padding:16px 18px; color:var(--ink-2); font-size:14px; }
  .notice.bad { border-color:color-mix(in srgb, var(--rec) 45%, var(--line)); color:var(--ink); }

  /* --- library grid ---------------------------------------------------------- */
  .grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(258px,1fr)); gap:clamp(14px,2vw,22px); }

  .tile { position:relative; border-radius:var(--r-md); background:var(--raise);
          border:1px solid var(--line); overflow:hidden; transition:border-color .2s var(--ease),
          transform .25s var(--ease), box-shadow .25s var(--ease); }
  .tile:hover { border-color:var(--line-hi); transform:translateY(-3px); box-shadow:var(--lift-2); }
  .tile .shot { display:block; position:relative; aspect-ratio:16/10; background:var(--raise-2) center/cover no-repeat; }
  /* The thumbnail darkens on hover so the play mark reads without a scrim over the art. */
  .tile .shot::after { content:''; position:absolute; inset:0; background:rgba(8,8,10,.42);
                       opacity:0; transition:opacity .25s var(--ease); }
  .tile:hover .shot::after { opacity:1; }
  .tile .play { position:absolute; inset:0; display:grid; place-items:center; opacity:0;
                transform:scale(.9); transition:opacity .25s var(--ease), transform .25s var(--ease); }
  .tile:hover .play, .tile:focus-within .play { opacity:1; transform:scale(1); }
  .tile .play i { width:52px; height:52px; border-radius:50%; background:rgba(246,245,243,.96);
                  box-shadow:var(--lift-2); display:grid; place-items:center; }
  .tile .play i::after { content:''; border-left:15px solid var(--black);
                         border-top:9px solid transparent; border-bottom:9px solid transparent; margin-left:4px; }
  .tile .len { position:absolute; right:10px; bottom:10px; font:500 10.5px/1 var(--mono);
               background:rgba(8,8,10,.78); backdrop-filter:blur(6px); color:var(--ink);
               padding:5px 7px; border-radius:6px; letter-spacing:.02em; }
  .tile .meta { padding:14px 16px 16px; }
  .tile .meta b { display:block; font:600 14.5px/1.35 var(--sans); letter-spacing:-.01em;
                  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .tile .when { font:400 10.5px/1 var(--mono); color:var(--ink-3); margin-top:6px;
                letter-spacing:.06em; text-transform:uppercase; }
  /* Actions stay out of the way until the tile is hovered or focused, so a wall of
     videos reads as a wall of videos and not a wall of buttons. */
  .tile .acts { display:flex; gap:6px; margin-top:14px; opacity:.001; transform:translateY(4px);
                transition:opacity .2s var(--ease), transform .2s var(--ease); }
  .tile:hover .acts, .tile:focus-within .acts { opacity:1; transform:none; }
  @media (hover:none) { .tile .acts { opacity:1; transform:none; } }
  .tile .acts button { padding:7px 10px; font-size:11.5px; background:transparent; }
  .tile.pending { opacity:.62; }
  .tile.pending .shot { background-image:none !important; }

  /* Something is happening: a slow sheen rather than a spinner. */
  .shimmer { position:relative; overflow:hidden; }
  .shimmer::after { content:''; position:absolute; inset:0; transform:translateX(-100%);
    background:linear-gradient(90deg, transparent, rgba(246,245,243,.07), transparent);
    animation:sheen 1.8s infinite; }

  /* --- watch page ------------------------------------------------------------ */
  .stage { min-height:100dvh; display:flex; flex-direction:column; justify-content:center; }
  .stage-in { width:100%; max-width:1180px; margin:0 auto; padding:clamp(14px,2.5vw,26px) var(--gutter) 60px; }
  /* The player floats on a pool of its own light: a wide, very soft halo under a black
     frame. It is the only object on the page allowed any presence. */
  .screen { position:relative; border-radius:var(--r-lg); overflow:hidden; background:#000;
            box-shadow:var(--lift-3), 0 0 0 1px var(--line); }
  .screen::before { content:''; position:absolute; inset:-14% -6% -22%; z-index:-1; border-radius:50%;
                    background:radial-gradient(ellipse at 50% 55%, rgba(246,245,243,.10), transparent 70%);
                    filter:blur(42px); }
  .screen video { width:100%; aspect-ratio:16/9; object-fit:contain; background:#000; }
  .veil { position:absolute; inset:0; display:grid; place-items:center; gap:14px;
          background:rgba(8,8,10,.72); backdrop-filter:blur(3px); font:500 11px/1 var(--mono);
          letter-spacing:.14em; text-transform:uppercase; color:var(--ink-2); }

  .titling { margin:30px 0 0; display:flex; gap:26px; align-items:flex-start; flex-wrap:wrap; }
  .titling h1 { font:400 clamp(28px,4.4vw,46px)/1.06 var(--display); letter-spacing:-.015em;
                margin:0; max-width:18ch; }
  .titling .facts { margin-left:auto; text-align:right; font:400 10.5px/1.9 var(--mono);
                    letter-spacing:.1em; text-transform:uppercase; color:var(--ink-3); }
  .from { font-size:14px; color:var(--ink-2); margin:10px 0 0; }
  .from b { color:var(--ink); font-weight:600; }
  .sig { margin-top:52px; padding-top:20px; border-top:1px solid var(--line);
         display:flex; align-items:center; gap:10px; font:400 10.5px/1 var(--mono);
         letter-spacing:.12em; text-transform:uppercase; color:var(--ink-3); }
  .sig .mark { font-size:11px; color:var(--ink-2); }

  /* --- dialogs --------------------------------------------------------------- */
  dialog { border:1px solid var(--line-hi); background:var(--raise); color:var(--ink);
           border-radius:var(--r-lg); padding:22px; max-width:min(440px,92vw);
           box-shadow:var(--lift-3); font:400 15px/1.55 var(--sans); }
  dialog::backdrop { background:rgba(4,4,6,.68); backdrop-filter:blur(4px); }
  dialog h3 { font:400 24px/1.2 var(--display); margin:0 0 10px; letter-spacing:-.01em; }
  dialog p { margin:0 0 20px; color:var(--ink-2); font-size:14px; }
  dialog input { width:100%; margin-bottom:18px; font-size:14px; padding:11px 12px; }

  .bar-progress { height:3px; background:var(--raise-2); border-radius:var(--r-pill); overflow:hidden; margin-top:14px; }
  .bar-progress i { display:block; height:100%; width:0; background:var(--ink);
                    transition:width .3s var(--ease); }
}

@layer motion {
  @keyframes beat { 50% { opacity:.25; } }
  @keyframes sheen { to { transform:translateX(100%); } }
  @keyframes rise { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }

  /* One orchestrated entrance per page. Tiles arrive in sequence, which makes a library
     feel dealt out rather than dumped. */
  .rise { animation:rise .5s var(--ease) both; }
  /* Only the first paint is animated. Re-running this on every refresh made the whole
     library flicker as though the page were reloading. */
  .grid.intro > * { animation:rise .5s var(--ease) both; animation-delay:calc(var(--i, 0) * 45ms); }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration:.01ms !important; animation-iteration-count:1 !important;
                             transition-duration:.01ms !important; }
  }
}

@media (max-width:560px) {
  .grid { grid-template-columns:repeat(auto-fill, minmax(150px,1fr)); gap:12px; }
  .tile .meta { padding:11px 12px 13px; }
  .tile .acts { flex-wrap:wrap; }
  .titling .facts { margin-left:0; text-align:left; }
}

@layer components {
  /* The play target on the watch page. Big, centred, and the only thing to do here. */
  .bigplay { position:absolute; inset:0; margin:auto; width:88px; height:88px; border-radius:50%;
             background:rgba(246,245,243,.95); border:0; box-shadow:var(--lift-3);
             display:grid; place-items:center; cursor:pointer; padding:0;
             transition:transform .2s var(--ease), background .2s var(--ease); }
  .bigplay:hover { transform:scale(1.06); background:#fff; }
  .bigplay i { width:0; height:0; margin-left:6px; border-left:26px solid var(--black);
               border-top:16px solid transparent; border-bottom:16px solid transparent; }

  /* Reserve the action row's space so nothing jumps on hover, but keep it tight. */
  .tile .acts { margin-top:11px; min-height:30px; }
}

@layer components {
  /* Live microphone level. Answers "is it hearing me?" during the recording, which is
     the only time the answer is any use. */
  .level { display:block; flex:1; max-width:220px; height:4px; background:var(--raise-2);
           border-radius:var(--r-pill); overflow:hidden; }
  .level i { display:block; height:100%; width:0; background:var(--ink);
             transition:width .1s linear; }
}
