/* structure.css — Structure and DDL tabs, export card and FK navigation (streams A6 then B8, main §5.3, §5.4).
   First version from WP0c: the .fk-link / .fk-locked arrows that _grid.phtml renders (structure.md §5.3c).
   A6 owns it afterwards. The core rule `td.is-editing .fk-link { display: none; }` stays in app.css. */

.fk-link { margin-left: .35rem; text-decoration: none; }
.fk-locked { color: var(--muted); cursor: not-allowed; }

/* Structure tab (A6, structure.md §5.3b). No inline styles anywhere: the sticky nav and the target highlight are
   pure CSS, and structure.js only sets aria-current. */
.struct-nav { position: sticky; top: var(--sticky-top, 0); z-index: 2; background: var(--bg, #fff);
  border-bottom: 1px solid var(--line); padding: .35rem 0; }
.struct-chips { display: flex; gap: .35rem; margin: 0; padding: 0; list-style: none;
  overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
.struct-chips li { flex: 0 0 auto; }
.struct-nav .chip { display: inline-block; padding: .15rem .5rem; border: 1px solid var(--line);
  border-radius: 999px; text-decoration: none; white-space: nowrap; }
.struct-nav .chip[aria-current="location"] { border-color: var(--accent, #35568a); font-weight: 600; }
.chip-count { color: var(--muted, #60656f); }
.struct-empty { margin: .25rem 0 0; }
.struct-overview .struct-facts { display: flex; flex-wrap: wrap; gap: .25rem .75rem; list-style: none;
  margin: .25rem 0; padding: 0; }
.struct-kind { font-weight: 600; margin: .5rem 0 .25rem; }
.struct-comment { white-space: pre-wrap; margin: .25rem 0 .75rem; }
.struct-table { width: 100%; border-collapse: collapse; }
.struct-table th, .struct-table td { text-align: left; vertical-align: top; padding: .25rem .5rem;
  border-bottom: 1px solid var(--line); }
.struct-table .col-comment { display: block; }
.struct-list { list-style: none; margin: .25rem 0; padding: 0; }
.struct-list > li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.enum-label + .enum-label::before { content: " · "; color: var(--muted, #60656f); }
/* The section partials render dozens of these (PK / UQ / FK → s.t, inherited, UNLOGGED, index flags, NOT VALID,
   DEFERRABLE, DEFAULT, via parent, type kind). `border-color` alone is inert, so the base rule carries the box. */
.badge { display: inline-block; padding: 0 .35rem; margin-left: .35rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--fg-soft); }
.badge-warn { border-color: var(--warn); color: var(--warn); }
section[id^="s-"] { scroll-margin-top: 4.5rem; }
.struct-table tr:target { outline: 2px solid var(--accent, #35568a);
  background: color-mix(in srgb, var(--accent-soft) 80%, transparent); }
@media (prefers-reduced-motion: reduce) { .struct-table tr:target { transition: none; } }

/* B8 (structure.md §5.3b): Triggers, Row security, Privileges and Statistics. */
.trigger-def summary { cursor: pointer; color: var(--muted); }
.trigger-def code { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
.trigger-state { color: var(--warn); }
.rls-status, .priv-owner, .your-access { margin: .25rem 0; }
/* The grid's "granted" texts are .visually-hidden (position: absolute): the wrapper must be their containing block,
   or a cell scrolled out of the wrapper still widens the page at 375 px. */
section[id^="s-"] .table-wrap { position: relative; }
.priv-grid td.priv-cell { text-align: center; }
.column-grants { margin-top: .5rem; }
.struct-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .25rem 1rem;
  margin: .25rem 0; }
.struct-stats div { display: flex; justify-content: space-between; gap: .5rem; padding: .15rem 0;
  border-bottom: 1px solid var(--line); }
.struct-stats dt { color: var(--muted); }
.struct-stats dd { margin: 0; font-variant-numeric: tabular-nums; }

/* B8 (structure.md §5.3c): the row page's References / Referenced by panel. */
.row-refs { margin-top: 1.5rem; }
.row-refs h3 { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: 1rem; margin: .75rem 0 .25rem; }
.row-refs .struct-list > li { overflow-wrap: anywhere; }
.refs-browse, .refs-open { margin-left: .5rem; }
.refcount { margin-left: .5rem; font-variant-numeric: tabular-nums; }
.refcount:empty { margin-left: 0; }
.refs-chain { margin: .5rem 0 0; }

/* B8 (structure.md §5.3d): the DDL tab. Every block scrolls inside itself; #ddl-all is visually hidden (Copy all). */
.ddl-tab { display: grid; gap: .75rem; min-width: 0; }
/* .visually-hidden sets white-space: nowrap; when the copy falls back to "manual", core.js selects #ddl-all and the
   selection would come out with every newline flattened, so the `--` notes would comment out the rest. */
.ddl-tab #ddl-all { white-space: pre; }
.ddl-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ddl-block { min-width: 0; }
.ddl-block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem; }
.ddl-block-head h2 { font-size: 1rem; margin: 0; }
pre.ddl { margin: .25rem 0 0; padding: .5rem .75rem; max-width: 100%; overflow: auto; background: var(--panel-alt);
  border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-mono); }
pre.ddl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
