/* ===========================================================
   Krdict Explorer — spider-web constellation view.

   The metaphor: each word is a star; clicking pulls that star
   to center and reveals its constellation of related words.
   Dark space-like canvas with thin glowing lines for the web
   feel, foreignObject overlays render the labels so we get
   crisp HTML typography inside the SVG layout.
   =========================================================== */
.krdict-explorer {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
    color: #e2e8f0;
}
/* Author CSS often sets `display:flex`/`grid`/etc on our containers,
   which beats the UA stylesheet's [hidden]{display:none} rule and
   leaves elements visible despite `element.hidden = true`. Force the
   global hide for anything inside the explorer. */
.krdict-explorer [hidden] { display: none !important; }

/* The whole thing lives inside a dark, starlit shell. */
.krdict-explorer-shell {
    position: relative;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(99,102,241,.18) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(168,85,247,.14) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 50%, #0e1233 0%, #050816 70%);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 24px 60px -20px rgba(0,0,0,.6);
}

/* Search bar — translucent glass at the top of the canvas. */
.krdict-search-form {
    position: absolute; z-index: 10;
    top: 18px; left: 18px; right: 18px;
    display: flex; gap: 8px;
    pointer-events: none;
}
.krdict-search-form > * { pointer-events: auto; }
.krdict-search-input {
    flex: 1; min-width: 0;
    padding: 11px 16px; font-size: 15px; line-height: 1.2;
    color: #f1f5f9;
    background: rgba(15, 23, 42, .55);
    border: 1px solid rgba(148,163,184,.25);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.krdict-search-input::placeholder { color: rgba(226,232,240,.55); }
.krdict-search-input:focus {
    outline: none;
    border-color: rgba(165,180,252,.7);
    box-shadow: 0 0 0 4px rgba(99,102,241,.18);
    background: rgba(15,23,42,.75);
}
.krdict-search-btn {
    padding: 0 22px; font-size: 14px; font-weight: 600;
    color: #f8fafc;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    border: none; border-radius: 999px; cursor: pointer;
    transition: filter .15s, transform .15s;
}
.krdict-search-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }

/* Breadcrumb trail — appears just below the search bar, also
   glass-translucent. */
.krdict-breadcrumbs {
    position: absolute; z-index: 9;
    top: 70px; left: 18px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
    padding: 6px 10px;
    background: rgba(15,23,42,.55);
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 999px;
    font-size: 11.5px;
    max-width: calc(100% - 36px);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.krdict-crumb {
    border: none; background: transparent;
    color: #c7d2fe;
    cursor: pointer; padding: 2px 6px;
    font-weight: 600; font-size: 11.5px;
    border-radius: 4px;
    transition: background-color .12s, color .12s;
}
.krdict-crumb:hover { background: rgba(99,102,241,.18); color: #f1f5f9; }
.krdict-crumb.is-current { color: #fff; background: rgba(99,102,241,.25); }
.krdict-crumb-sep { color: rgba(165,180,252,.5); margin: 0 1px; user-select: none; }

/* The status chip — same position as before but dark-themed. */
.krdict-status {
    position: absolute; z-index: 8;
    left: 50%; transform: translateX(-50%);
    bottom: 18px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 12.5px; line-height: 1;
    border: 1px solid transparent;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.krdict-status.is-loading { background: rgba(99,102,241,.18); color: #c7d2fe; border-color: rgba(165,180,252,.4); }
.krdict-status.is-success { background: rgba(16,185,129,.15);  color: #6ee7b7; border-color: rgba(110,231,183,.4); }
.krdict-status.is-error   { background: rgba(239, 68, 68,.18); color: #fca5a5; border-color: rgba(252,165,165,.4); }

/* Disambiguation list when search returns multiple hits — appears
   as a floating glass card. */
.krdict-results {
    position: absolute; z-index: 9;
    top: 72px; left: 50%; transform: translateX(-50%);
    width: min(540px, calc(100% - 36px));
    max-height: 60%;
    overflow-y: auto;
    padding: 10px;
    background: rgba(15,23,42,.85);
    border: 1px solid rgba(148,163,184,.25);
    border-radius: 14px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: grid; gap: 6px;
}
.krdict-result-row {
    display: flex; flex-direction: column; gap: 4px;
    padding: 9px 12px;
    background: rgba(30,41,59,.5);
    border: 1px solid rgba(148,163,184,.15);
    border-radius: 8px;
    text-align: left; cursor: pointer; font: inherit;
    color: inherit;
    transition: background .12s, border-color .12s;
}
.krdict-result-row:hover {
    background: rgba(99,102,241,.2);
    border-color: rgba(165,180,252,.5);
}
.krdict-result-word    { font-size: 16px; font-weight: 600; color: #f1f5f9; }
.krdict-result-example { font-size: 12.5px; color: #94a3b8; line-height: 1.4; }

/* === The Web — HTML canvas the rAF loop draws into. === */
.krdict-web-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 480px;
    max-height: 760px;
}
.krdict-canvas {
    display: block;
    width: 100%;
    height: 100%;
}
/* (Canvas handles all the mesh rendering — see krdict-explorer.js.
    No SVG/text node CSS needed; styling is done with ctx fillStyle /
    strokeStyle / shadowBlur in the rAF tick.) */

/* Empty hint when no word is loaded yet. */
.krdict-empty-hint {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 12px;
    color: rgba(226,232,240,.7);
    text-align: center;
    pointer-events: none;
}
.krdict-empty-hint h2 {
    margin: 0; font-size: 28px; font-weight: 600;
    background: linear-gradient(120deg, #a5b4fc 0%, #f0abfc 60%, #67e8f9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}
.krdict-empty-hint p { margin: 0; font-size: 14px; opacity: .75; }

/* === The detail drawer slides up from the bottom of the canvas
       after a word loads. Contains definition + examples; the
       constellation above is the navigator. === */
.krdict-drawer {
    background: rgba(15,23,42,.95);
    border-top: 1px solid rgba(148,163,184,.18);
    padding: 18px 22px 22px;
    color: #e2e8f0;
}
.krdict-drawer[hidden] { display: none; }
.krdict-drawer-head {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px;
    margin-bottom: 10px;
}
.krdict-drawer-word {
    font-size: 22px; font-weight: 700; margin: 0;
    color: #f8fafc; letter-spacing: -0.01em;
}
.krdict-drawer-pron {
    font-size: 13px; color: #94a3b8;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.krdict-audio-btn {
    margin-left: auto; padding: 5px 12px; font-size: 11px; font-weight: 600;
    color: #c7d2fe; background: rgba(99,102,241,.18);
    border: 1px solid rgba(165,180,252,.4); border-radius: 999px;
    cursor: pointer; transition: background-color .12s;
}
.krdict-audio-btn:hover { background: rgba(99,102,241,.35); }
.krdict-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.krdict-chip {
    padding: 2px 9px; font-size: 10px; font-weight: 700;
    background: rgba(148,163,184,.18); color: #cbd5e1;
    border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.krdict-chip-grade  { background: rgba(16,185,129,.18);  color: #6ee7b7; }
.krdict-chip-origin {
    background: rgba(245,158,11,.16); color: #fde68a;
    font-family: serif; text-transform: none; letter-spacing: 0;
}
.krdict-chip-cat    {
    background: rgba(99,102,241,.18); color: #c7d2fe;
    text-transform: none; letter-spacing: 0;
}
.krdict-definition {
    font-size: 15px; line-height: 1.6;
    color: #f1f5f9;
    padding: 10px 14px;
    background: rgba(99,102,241,.08);
    border-left: 2px solid rgba(165,180,252,.6);
    border-radius: 4px;
    margin: 0 0 16px;
}
.krdict-examples-title {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    color: #94a3b8; letter-spacing: 0.08em;
    margin: 14px 0 6px;
}
.krdict-examples {
    list-style: none; padding: 0; margin: 0;
    display: grid; gap: 4px;
}
.krdict-example {
    padding: 8px 12px;
    background: rgba(30,41,59,.55);
    border: 1px solid rgba(148,163,184,.12);
    border-radius: 6px;
    display: flex; gap: 10px; align-items: baseline;
}
.krdict-example-type {
    font-size: 9px; font-weight: 700; padding: 1px 6px;
    background: rgba(15,23,42,.6); border: 1px solid rgba(148,163,184,.2);
    border-radius: 3px;
    text-transform: uppercase; color: #94a3b8;
    flex-shrink: 0; letter-spacing: 0.05em;
}
.krdict-example-phrase .krdict-example-type {
    background: rgba(245,158,11,.15); border-color: rgba(252,211,77,.3);
    color: #fde68a;
}
.krdict-example-text {
    margin: 0; line-height: 1.55; color: #f1f5f9; font-size: 14px;
}
.krdict-eojeol {
    cursor: pointer;
    padding: 1px 3px;
    border-radius: 3px;
    transition: background-color .1s, color .1s;
}
.krdict-eojeol:hover { background: rgba(99,102,241,.25); color: #fff; }

@media (max-width: 600px) {
    .krdict-web-wrap { min-height: 380px; aspect-ratio: 4 / 3; }
    .krdict-web .center-text { font-size: 32px; }
    .krdict-web .node-label  { font-size: 12px; }
}
