/* --------------------------------------------------------------------------
   Learning Philosophy - pan-and-zoom graph

   Layout only. Colour and type come from brand.css.

   The whole page is one sticky stage holding an absolutely-positioned canvas.
   Children of the canvas are placed in canvas coordinates via left/top and
   counter-scaled by js/philosophy-graph.js, so their pixel size stays put
   while the field expands. Nothing here animates on its own - every transform
   is written by the engine.
   -------------------------------------------------------------------------- */

.phil-graph {
    position: relative;
    background: var(--uf-ink);
}

.phil-graph__host {
    position: relative;
    width: 100%;
    height: var(--phil-vh, 100dvh);
    overflow: hidden;
}

.phil-graph__stage {
    position: sticky;
    top: 0;
    width: 100%;
    height: var(--phil-vh, 100dvh);
    overflow: hidden;
    background: var(--uf-ink);
    cursor: grab;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.phil-graph.is-dragging .phil-graph__stage {
    cursor: grabbing;
}

/* Fluid-ink background ---------------------------------------------------
   The same treatment as the blog cover (css/flow-pages.css .blx-hero__*):
   a blurred violet bloom as the static floor, the WebGL fluid simulation
   (js/fluid-hero.js, mounted on [data-fluid-hero]) painting cursor-driven
   ink additively over it, and a veil on top so the tiles stay readable.
   Under prefers-reduced-motion the script removes its canvas and the bloom
   carries the stage on its own.
   ----------------------------------------------------------------------- */

.phil-graph__bloom {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.75;
}

.phil-graph__bloom::before {
    content: '';
    position: absolute;
    top: -10%;
    left: 50%;
    width: 92%;
    height: 120%;
    transform: translateX(-50%) rotate(-18deg);
    background: linear-gradient(
        200deg,
        rgba(99, 79, 204, 0) 12%,
        rgba(104, 84, 214, 0.3) 38%,
        rgba(122, 94, 236, 0.26) 56%,
        rgba(64, 48, 148, 0.14) 76%,
        transparent 92%
    );
    filter: blur(80px);
}

.phil-graph__bloom::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(46% 46% at 50% 48%, rgba(126, 104, 224, 0.2), transparent 72%);
    filter: blur(60px);
}

.phil-graph__fluid {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    /* Lower than the blog's 0.85: here the ink sits behind a whole field of
       tiles and labels rather than one headline. */
    opacity: 0.62;
}

.phil-graph__veil {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(58% 42% at 50% 50%, rgba(10, 10, 11, 0.5), rgba(10, 10, 11, 0) 78%),
        linear-gradient(0deg, rgba(10, 10, 11, 0.55) 0%, rgba(10, 10, 11, 0) 34%);
}

/* The graph canvas carries its own stacking context so that the hero words
   (.phil-word, z-index -1, deliberately behind the tiles) stay inside it and
   above the ink layers rather than dropping behind them. */
.phil-graph__canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    transform-origin: 0 0;
    will-change: transform;
    transition: filter 0.28s var(--uf-ease);
}

.phil-graph.is-focused .phil-graph__canvas {
    filter: blur(10px);
}

/* Connectors ------------------------------------------------------------ */

.phil-graph__lines {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    pointer-events: none;
}

/* The reference strokes these in its foreground ink at 40%, not in an accent
   colour - the connectors are meant to read as faint pencil, not as brand.
   Inverted here for a dark ground: paper instead of ink, same weight. */
.phil-graph__lines line {
    stroke: var(--uf-paper);
    stroke-width: 1;
}

/* Tiles ----------------------------------------------------------------- */

.phil-node {
    position: absolute;
    padding: 0;
    border: none;
    border-radius: var(--flow-radius-sm, 16px);
    background-color: var(--uf-ink-panel);
    background-position: 50%;
    background-size: cover;
    background-repeat: no-repeat;
    transform-origin: 50% 50%;
    will-change: transform, opacity;
    cursor: pointer;
    opacity: 0;
}

.phil-node--bordered {
    box-shadow: inset 0 0 0 1px var(--uf-hairline);
}

/* Culled tiles and their connectors - see updateCulling(). Stated explicitly
   because a `display` declaration on the element would outrank the UA rule
   for the hidden attribute. */
.phil-node[hidden],
.phil-label[hidden],
.phil-graph__lines line[hidden] {
    display: none;
}

.phil-node:hover,
.phil-node:focus-visible {
    z-index: 20;
    outline: 1px solid var(--flow-accent-bright, #8b5cf6);
    outline-offset: 2px;
}

/* Cluster labels -------------------------------------------------------- */

.phil-label {
    position: absolute;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 212px;
    text-align: center;
    color: var(--uf-text);
    pointer-events: none;
    will-change: transform, opacity;
    opacity: 0;
}

.phil-label__text {
    font-family: var(--flow-display);
    font-weight: 500;
    font-size: 19px;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.phil-label__blurb {
    margin-top: 10px;
    font-family: var(--uf-sans);
    font-size: 13px;
    line-height: 1.5;
    color: var(--uf-text-dim);
}

/* Hero words ------------------------------------------------------------ */

.phil-word {
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
    margin: 0;
    font-family: var(--flow-display);
    font-weight: 500;
    /* Counter-scaled to constant pixel size by the engine, so this is the
       on-screen size: full 104px on laptops, shrinking with the viewport so
       a word centred near an edge cannot bleed off a phone screen. */
    font-size: clamp(40px, 11vw, 104px);
    line-height: 1;
    letter-spacing: -0.03em;
    white-space: nowrap;
    color: var(--uf-text);
    transform-origin: 50% 50%;
    will-change: transform;
    cursor: grab;
    touch-action: none;
}

.phil-word:active {
    cursor: grabbing;
}

/* Hero blurb ------------------------------------------------------------ */

.phil-graph__blurb {
    position: absolute;
    left: 50%;
    /* Anchored from the bottom, not a viewport percentage: below it sit the
       scroll hint and then the floating dock, and a percentage top let the
       CTA drift into them on shorter screens. 1.4rem dock offset + ~58px
       dock + 16px gap + ~39px hint + 17px gap. */
    top: auto;
    bottom: calc(1.4rem + 130px);
    z-index: 6;
    width: min(42rem, 82vw);
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

.phil-graph__blurb p {
    margin: 0;
    font-size: clamp(0.95rem, 1.5vw, 1.0625rem);
    line-height: 1.6;
    color: var(--uf-text-dim);
    text-align: left;
}

/* Stage chrome ---------------------------------------------------------- */

.phil-graph__hint {
    position: absolute;
    left: 50%;
    /* The floating dock (home-flow.css) sits fixed at bottom centre —
       1.4rem off the edge plus its own ~58px height — so the hint has to
       hover above it rather than at its old 5vh. */
    bottom: calc(1.4rem + 76px);
    z-index: 7;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--uf-hairline);
    border-radius: 999px;
    background: var(--uf-ink-raised);
    color: var(--uf-text-dim);
    font-family: var(--uf-sans);
    font-size: 0.875rem;
    cursor: pointer;
    transform: translateX(-50%);
}

.phil-graph__hint .phil-graph__arrow {
    transition: transform 0.5s var(--uf-ease);
}

.phil-graph__hint.is-nudging .phil-graph__arrow {
    animation: phil-nudge 2.4s var(--uf-ease) infinite;
}

@keyframes phil-nudge {
    0%, 70%, 100% { transform: translateY(0); }
    80% { transform: translateY(4px); }
    90% { transform: translateY(0); }
}

.phil-graph__clickhint,
.phil-graph__zoom {
    position: absolute;
    bottom: 24px;
    z-index: 7;
    font-family: var(--uf-sans);
    font-size: 0.8125rem;
    color: var(--uf-text-dim);
    opacity: 0;
    transition: opacity 0.4s var(--uf-ease);
    pointer-events: none;
}

.phil-graph.is-bloomed .phil-graph__clickhint,
.phil-graph.is-bloomed .phil-graph__zoom {
    opacity: 1;
    pointer-events: auto;
}

.phil-graph__clickhint {
    left: var(--uf-gutter);
    margin: 0;
    padding: 9px 16px;
    border: 1px solid var(--uf-hairline);
    border-radius: 999px;
    background: var(--uf-ink-raised);
}

.phil-graph__zoom {
    right: var(--uf-gutter);
    display: flex;
    align-items: center;
    gap: 8px;
}

.phil-graph__zoom-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--uf-hairline);
    border-radius: 50%;
    background: var(--uf-ink-raised);
    color: var(--uf-text);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s var(--uf-ease);
}

.phil-graph__zoom-btn:hover:not(:disabled) {
    background: var(--uf-ink-panel);
}

.phil-graph__zoom-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Focus card ------------------------------------------------------------ */

.phil-graph__backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(10, 10, 11, 0.65);
    opacity: 0;
    transition: opacity 0.2s var(--uf-ease);
}

.phil-graph.is-card-in .phil-graph__backdrop {
    opacity: 1;
}

/* The focus stack: enlarged tile floating above a card that is a touch
   wider, both centred as one unit. Mirrors the reference's composition,
   rendered in the UniFluent dark brand. */
.phil-focus {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 51;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(30rem, 90vw);
    transform: translate(-50%, -48%) scale(0.98);
    opacity: 0;
    transition: opacity 0.22s var(--uf-ease), transform 0.22s var(--uf-ease);
}

.phil-graph.is-card-in .phil-focus {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.phil-focus[hidden] {
    display: none;
}

.phil-focus__thumb {
    /* ~87% of the card width, matching the reference's proportion. */
    width: min(24rem, 87%);
    /* Portrait crop, as the reference uses. */
    aspect-ratio: 4 / 5;
    max-height: 44vh;
    background-color: var(--uf-ink-raised);
    background-position: 50%;
    background-size: cover;
    background-repeat: no-repeat;
    border-radius: var(--flow-radius-sm, 16px);
    /* Several tile recipes are almost the same value as the card behind them,
       so without this the thumbnail loses its edges entirely. */
    box-shadow: inset 0 0 0 1px var(--uf-hairline), 0 12px 30px rgba(0, 0, 0, 0.45);
}

.phil-card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    /* Lift the card so it tucks under the image, as in the reference. */
    margin-top: -14px;
    padding: 18px 24px 24px 28px;
    border: 1px solid var(--uf-hairline);
    border-radius: var(--flow-radius, 28px);
    background: var(--uf-ink-panel);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}

.phil-card__head {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.8125rem;
    line-height: 1;
    color: var(--uf-text-faint);
}

.phil-card__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: auto;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #202027;
    color: #e6e6ea;
    font-size: 0.875rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.18s var(--uf-ease);
}

.phil-card__close:hover {
    background: var(--flow-accent, #6c4cf1);
    color: #f4f2ff;
}

.phil-card__title {
    margin-top: 2px;
    max-width: 30ch;
    font-family: var(--flow-display);
    font-weight: 500;
    font-size: clamp(1.375rem, 2.4vw, 1.75rem);
    line-height: 1.16;
    letter-spacing: -0.02em;
    color: var(--uf-text);
    text-decoration: none;
    text-wrap: pretty;
}

.phil-card__title:hover {
    text-decoration: underline;
}

.phil-card__themes {
    margin: 2px 0 0;
    font-size: 0.9375rem;
    line-height: 1.45;
    color: var(--uf-text-dim);
}

.phil-card__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    align-self: flex-start;
    margin-top: 10px;
    padding: 10px 22px;
    border-radius: 96px;
    background: var(--flow-accent, #6c4cf1);
    color: #f4f2ff;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    transition: background 0.18s var(--uf-ease), transform 0.3s var(--uf-ease);
}

.phil-card__cta::after {
    content: '\2192';
}

.phil-card__cta:hover {
    background: var(--flow-accent-bright, #8b5cf6);
    transform: translateY(-2px);
}

/* Narrow viewports ------------------------------------------------------ */

@media (max-width: 760px) {
    .phil-word {
        font-size: 64px;
    }

    .phil-label {
        width: 160px;
    }

    .phil-label__text {
        font-size: 16px;
    }

    .phil-label__blurb {
        display: none;
    }

    .phil-graph__clickhint {
        display: none;
    }

    /* On narrow viewports the dock stretches to nearly full width, so the
       zoom buttons move up out of its way (clearance published by
       home-flow.css, which every dock page loads). */
    .phil-graph__zoom {
        bottom: var(--uf-dock-clearance, calc(1rem + 76px));
    }
}
