/*
 * A PARAMETRIC DRAWING, not a laid-out surface. Every measure here is a rounded
 * fraction of the badge's own width — `size` is the one datum — so each arrives
 * as a custom property the component computes (§5 rule 11) rather than as a
 * `calc()` naming lengths of its own. That is also what keeps the rounding: at
 * 26px the rule is 2px, and a fractional 1.5 renders as a grey smear.
 *
 * The type is the one measure that does NOT scale freely: the label and the
 * stamp land on the ramp's nearest rung and are DROPPED under its floor, which
 * the component decides — a fraction of 26px has no rung to take.
 * `--lotics-file-badge-tracking` is the component's own micro-typography and is
 * declared here, beside the drawing it belongs to.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-file-badge {
    --lotics-file-badge-tracking: 0.3px;
    --lotics-file-badge-stamp-tracking: 0.2px;
    /* The paper's own hairline, and the ruled lines on it: translucent ink over
       the shadow token rather than a fourth grey, so a theme moves both. */
    --lotics-file-badge-hairline: color-mix(in srgb, var(--lotics-shadow-color) 8%, transparent);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-shrink: 0;
    width: var(--lotics-file-badge-w);
    height: var(--lotics-file-badge-h);
    border-radius: var(--lotics-file-badge-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px var(--lotics-file-badge-hairline);
  }

  /* A PRESS TARGET AROUND NOTHING ELSE — the drawing IS the button, so the
     browser's own button chrome is taken off and the mark keeps its own corner,
     which the ring then follows. A file's face is content rather than a verb
     (`DocumentCard` and `MediaCard` say the same), so the pointer does not
     change over it. */
  .lotics-file-badge[data-pressable] {
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    appearance: none;
    cursor: default;
  }

  /* THE SAME SCRIM THE PICTURE TILE WEARS (`file_thumbnail.css`), because in a
     mixed strip they are the same control: three pictures that light up under
     the pointer beside a PDF that does nothing states that one tile of the four
     cannot be pressed. A scrim ON TOP rather than a ground behind, for the
     reason the picture has one — the badge paints its own paper and its type
     band, and a wash under either is invisible. */
  .lotics-file-badge[data-pressable]::after {
    content: "";
    position: absolute;
    inset: 0;
    background-color: transparent;
    pointer-events: none;
    transition: background-color var(--lotics-duration-fast) var(--lotics-ease-standard);
  }

  .lotics-file-badge[data-pressable]:hover::after {
    background-color: var(--lotics-scrim-hover);
  }

  .lotics-file-badge[data-pressable]:active::after {
    background-color: var(--lotics-scrim-press);
  }

  .lotics-file-badge[data-pressable]:focus-visible {
    outline: var(--lotics-ring-width) solid var(--ring);
    outline-offset: 0;
  }

  /* A GHOST SLOT — an expected document nobody has provided yet, at the exact
     footprint of the real badge so a pending row lines up pixel for pixel. */
  .lotics-file-badge[data-placeholder] {
    align-items: center;
    justify-content: center;
    border-width: var(--lotics-file-badge-border);
    border-style: dashed;
    border-color: var(--input);
    background-color: var(--muted);
    box-shadow: none;
    --lotics-icon-color: var(--lotics-ink-inactive);
  }

  .lotics-file-badge__sheet {
    /* The stamp centres on the PAPER, not on the whole badge — the coloured
       band below it is not part of the sheet the stamp is stamped on. */
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding-top: var(--lotics-file-badge-pad-y);
    padding-inline: var(--lotics-file-badge-pad-x);
    gap: var(--lotics-file-badge-line-gap);
    border-width: 1px 1px 0;
    border-style: solid;
    border-color: var(--lotics-file-badge-hairline);
    border-start-start-radius: var(--lotics-file-badge-radius);
    border-start-end-radius: var(--lotics-file-badge-radius);
    background-color: var(--card);
  }

  /* PLAYABLE MEDIA fills the paper with the type's own colour and centres one
     glyph: a video has no ruled lines to draw. */
  .lotics-file-badge__sheet[data-media] {
    align-items: center;
    justify-content: center;
    padding-top: 0;
    padding-inline: 0;
    gap: 0;
    background-color: var(--lotics-file-badge-ink);
    --lotics-icon-color: var(--lotics-white);
  }

  .lotics-file-badge__rule {
    display: block;
    height: var(--lotics-file-badge-rule-h);
    /* A CAP, not a corner: the pill rung clamps to half of a 1.5px line, which
       is the rounded hairline this drew with a 1px literal. */
    border-radius: var(--lotics-radius-full);
    background-color: var(--lotics-file-badge-hairline);
  }

  .lotics-file-badge__rule[data-last] {
    width: 60%;
  }

  .lotics-file-badge__band {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: var(--lotics-file-badge-band-h);
    background-color: var(--lotics-file-badge-ink);
    border-end-start-radius: var(--lotics-file-badge-radius);
    border-end-end-radius: var(--lotics-file-badge-radius);
  }

  .lotics-file-badge__label {
    font-family: var(--font-sans);
    font-size: var(--lotics-file-badge-label-size);
    line-height: var(--lotics-file-badge-label-leading);
    letter-spacing: var(--lotics-file-badge-tracking);
    font-weight: var(--lotics-weight-semibold);
    /* WHITE, not the inverse ink: the band keeps its saturated colour in a dark
       theme, so the ink on it must not flip with the surface. */
    color: var(--lotics-white);
  }

  /* The TEMPLATE stamp, centred over the paper. `inset: 0` plus `margin: auto`
     over a shrink-to-fit box is the centring — an offset from one corner would
     have to know the chip's own size, which changes with the badge's. */
  .lotics-file-badge__stamp {
    position: absolute;
    inset: 0;
    margin: auto;
    width: fit-content;
    height: fit-content;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding-inline: var(--lotics-file-badge-stamp-pad-x);
    padding-block: var(--lotics-file-badge-stamp-pad-y);
    border-radius: var(--lotics-file-badge-stamp-radius);
    background-color: var(--lotics-white);
    font-family: var(--font-sans);
    font-size: var(--lotics-file-badge-stamp-size);
    line-height: normal;
    letter-spacing: var(--lotics-file-badge-stamp-tracking);
    font-weight: var(--lotics-weight-semibold);
    color: var(--lotics-ink-default);
    box-shadow: 0 0.5px 1px color-mix(in srgb, var(--lotics-shadow-color) 10%, transparent);
  }
}
