/* =============================================================================
   base.css — reset, element defaults, focus, selection, print isolation.

   Loaded third: fonts → tokens → base → layout → components → viz → screens.
   Nothing here knows about a component. Everything here is an element
   selector, a global utility that is genuinely global, or an accessibility
   guarantee.
   ========================================================================= */

/* --- reset --------------------------------------------------------------- */

*,*::before,*::after{ box-sizing:border-box; }

html,body,h1,h2,h3,h4,h5,h6,p,figure,blockquote,dl,dd,ol,ul,pre{
  margin:0; padding:0;
}
ul[role="list"],ol[role="list"],.list-reset{ list-style:none; }

html{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
  tab-size:2;
  scrollbar-color:var(--line-2) transparent;
  scrollbar-width:thin;
}

body{
  min-height:100vh;
  min-height:100dvh;
  background:var(--ink);
  color:var(--text);
  font-family:var(--font-text);
  font-size:var(--fs-body);
  line-height:var(--lh);
  font-weight:var(--fw-regular);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeLegibility;
  font-variant-numeric:tabular-nums lining-nums;
  overflow-wrap:break-word;
}

/* --- headings ------------------------------------------------------------ */

h1,h2,h3,h4,h5,h6{
  font-family:var(--font-display);
  font-weight:var(--fw-semi);
  line-height:var(--lh-tight);
  letter-spacing:var(--ls-tight);
  color:var(--text);
  text-wrap:balance;
}
h1{ font-size:var(--fs-h1); }
h2{ font-size:var(--fs-h2); }
h3{ font-size:var(--fs-h3); }
h4,h5,h6{ font-size:var(--fs-body); }

/* Armenian letterforms connect; negative tracking closes them into mush, and
   the display faces are optically smaller to start with. No tightening. */
:lang(hy) h1,:lang(hy) h2,:lang(hy) h3,:lang(hy) h4,:lang(hy) h5,:lang(hy) h6{
  letter-spacing:0;
}

p{ text-wrap:pretty; }

/* --- links --------------------------------------------------------------- */

a{
  color:var(--link);
  text-decoration:none;
  text-underline-offset:.18em;
  text-decoration-thickness:1px;
}
a:hover{ text-decoration:underline; }
a:not([class]){ text-decoration:underline; text-decoration-color:var(--cyan-line); }

/* --- media --------------------------------------------------------------- */

img,svg,video,canvas,picture{ display:block; max-width:100%; }
svg{ fill:currentColor; }

/* --- type utilities that are genuinely global ---------------------------- */

b,strong{ font-weight:var(--fw-semi); }
small,.tiny{ font-size:var(--fs-xs); line-height:var(--lh-snug); }
.sm{ font-size:var(--fs-sm); }
.muted{ color:var(--text-2); }
.faint{ color:var(--text-3); }
.err{ color:var(--bad-fg); font-size:var(--fs-sm); min-height:1.15em; }
.ok-text{ color:var(--ok-fg); }
.nowrap{ white-space:nowrap; }
.truncate{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.stack>*+*{ margin-top:var(--sp-3); }

code,kbd,samp,pre{
  font-family:var(--font-data);
  font-size:.92em;
  font-variant-numeric:tabular-nums;
}
code{ background:var(--code-bg); border-radius:var(--r-chip); padding:.08em .34em; }
pre{ background:var(--code-bg); border-radius:var(--r-chip-lg); padding:var(--sp-3);
     overflow:auto; }
pre code{ background:none; padding:0; }

hr{ border:0; border-top:1px solid var(--line); margin:var(--sp-5) 0; }

/* --- forms: element defaults, so unclassed inputs still look right -------- */

button,input,select,textarea,optgroup{
  font:inherit;
  font-family:var(--font-text);
  color:inherit;
  letter-spacing:inherit;
}
button{ background:none; border:none; padding:0; cursor:pointer; color:inherit; }
button:disabled,input:disabled,select:disabled,textarea:disabled{
  opacity:.5; cursor:not-allowed;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea{
  width:100%;
  min-height:40px;
  padding:var(--sp-2) var(--sp-3);
  background:var(--surface-2);
  color:var(--text);
  border:1px solid var(--line);
  border-radius:var(--r-chip-lg);
  font-size:var(--fs-sm);
  outline:none;
  transition:border-color var(--dur-1) var(--ease),
             background var(--dur-1) var(--ease),
             box-shadow var(--dur-1) var(--ease);
}
textarea{ resize:vertical; line-height:var(--lh); }
input::placeholder,textarea::placeholder{ color:var(--text-3); }

input:hover:not(:disabled),select:hover:not(:disabled),textarea:hover:not(:disabled){
  border-color:var(--line-2);
}
input:focus,select:focus,textarea:focus{
  border-color:var(--cyan);
  background:var(--surface-3);
  box-shadow:0 0 0 3px var(--cyan-weak);
}
/* Dates and selects render their own indicators; keep them on-brand. */
select{
  appearance:none;
  padding-right:var(--sp-7);
  background-image:linear-gradient(45deg,transparent 50%,currentColor 50%),
                   linear-gradient(135deg,currentColor 50%,transparent 50%);
  background-position:calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size:5px 5px,5px 5px;
  background-repeat:no-repeat;
}
::-webkit-calendar-picker-indicator{ filter:invert(var(--picker-invert,1)); opacity:.6; cursor:pointer; }
:root[data-theme="light"]{ --picker-invert:0; }

fieldset{ border:1px solid var(--line); border-radius:var(--r-chip-lg); padding:var(--sp-4); }
legend{ padding:0 var(--sp-2); color:var(--text-2); font-size:var(--fs-sm); }

/* --- tables -------------------------------------------------------------- */

table{ border-collapse:collapse; border-spacing:0; }
th{ text-align:start; font-weight:var(--fw-semi); }

/* --- details/summary ----------------------------------------------------- */

summary{ cursor:pointer; }
summary::-webkit-details-marker{ display:none; }

/* --- focus: one visible ring, everywhere, in cyan ------------------------

   :focus-visible only — a mouse click on a card must not light up, a Tab must.
   The offset + the contrasting inner shadow keep the ring legible on Ink AND
   on a cyan button, where a plain cyan outline would vanish.
   ---------------------------------------------------------------------- */

:focus{ outline:none; }

:focus-visible{
  outline:var(--focus-w) solid var(--focus-color);
  outline-offset:var(--focus-offset);
  border-radius:var(--r-chip);
}
/* Elements with their own radius keep it; the ring follows the shape. */
.btn:focus-visible,.chip:focus-visible,.tabs__tab:focus-visible,
.rail__item:focus-visible,.card:focus-visible{ border-radius:inherit; }

input:focus-visible,select:focus-visible,textarea:focus-visible{
  outline-offset:1px;
}

/* Windows/Edge forced-colours: let the OS palette through rather than
   fighting it with token colours it will override anyway. */
@media (forced-colors:active){
  :focus-visible{ outline:2px solid CanvasText; }
  .btn,.chip,.badge,.card{ border:1px solid CanvasText; }
}

/* --- selection ----------------------------------------------------------- */

::selection{ background:var(--cyan); color:var(--on-accent); }
::-moz-selection{ background:var(--cyan); color:var(--on-accent); }

/* --- scrollbars (WebKit; Firefox uses scrollbar-color above) -------------- */

::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{
  background:var(--line-2);
  border-radius:var(--r-pill);
  border:3px solid transparent;
  background-clip:content-box;
}
::-webkit-scrollbar-thumb:hover{ background:var(--text-3); background-clip:content-box; }

/* --- accessibility helpers ----------------------------------------------- */

.visually-hidden:not(:focus):not(:active){
  position:absolute;
  width:1px; height:1px;
  overflow:hidden;
  clip-path:inset(50%);
  white-space:nowrap;
}
.skip-link{
  position:absolute; inset-inline-start:var(--sp-3); inset-block-start:-100%;
  z-index:100;
  padding:var(--sp-2) var(--sp-4);
  background:var(--cyan); color:var(--on-accent);
  border-radius:var(--r-btn); font-weight:var(--fw-semi);
}
.skip-link:focus{ inset-block-start:var(--sp-3); }

[hidden]{ display:none !important; }
[aria-busy="true"]{ cursor:progress; }

/* --- motion: one global neutraliser --------------------------------------

   Everything decorative in this stylesheet set is either written inside
   `@media (prefers-reduced-motion: no-preference)` or killed here. This block
   is the backstop, not the plan — a component must still look finished when
   its animation never runs.
   ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{
    animation-duration:.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.001ms !important;
    scroll-behavior:auto !important;
  }
}
@media (prefers-reduced-motion: no-preference){
  html{ scroll-behavior:smooth; }
}

/* --- print: isolate the report -------------------------------------------

   Ported from app.css. The rule is unchanged: chrome never prints, only the
   view that is on screen prints, and the report loses its card treatment so
   it lands on paper as a document rather than as a screenshot of a panel.
   The palette flip lives in tokens.css (print @media), because colour is
   tokens.css's job.
   ---------------------------------------------------------------------- */

@media print{
  html,body{
    height:auto; min-height:0;
    background:var(--ink); color:var(--text);
    font-size:11pt;
  }

  /* chrome — none of this is part of the document */
  .rail,.side,.nav,.topbar,.toolbar,.composer,.chat-list,.chat__list,
  .role-tabs,.tabs,.chatfab,.fab,.toast,.toasts,.modal,.disclosure,
  .suggest,.skip-link,.no-print,#dashHello{
    display:none !important;
  }

  .app,.shell{ display:block !important; height:auto !important; overflow:visible !important; }
  .main,.content,.content__inner,.chat__main,.chat__scroll{
    display:block !important;
    height:auto !important; max-height:none !important;
    overflow:visible !important;
    padding:0 !important; margin:0 !important;
    max-width:none !important;
  }

  .view{ display:none !important; }
  .view.active,.view.is-active,.screen{ display:block !important; padding:0; max-width:none; }

  .report{ border:0; box-shadow:none; padding:0; background:transparent; max-width:none; }
  .card{ border:1px solid var(--line); box-shadow:none; break-inside:avoid; }
  .print-only{ display:revert !important; }

  h1,h2,h3{ break-after:avoid; }
  table,figure,.viz{ break-inside:avoid; }
  thead{ display:table-header-group; }

  a[href^="http"]::after{ content:" (" attr(href) ")"; font-size:.85em; color:var(--text-3); }
}
.print-only{ display:none; }
