@import url('./brand-colors.css');

/* ── Typography tokens — single source of truth for the entire project ──
   Every page (nest, dashboard, portal, admin GUI, user GUI) loads this file
   via <link rel="stylesheet" href="/assets/brand.css">, so changing these
   values once retypes everything. Each font-family declaration in the codebase
   uses var(--cr-font-sans) / var(--cr-font-mono) with the same fallback chain
   in case brand.css fails to load. */
:root {
  --cr-font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --cr-font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  /* The lockup's own font, whatever the page's text is set in (Inter on
     every page that links assets/nest-type.css). */
  --cr-font-brand: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Circloud NEST brand block — single source of truth.
   Used in header, nest hero, login pages, portal, description.js, and inside
   the nest page's SVG diagrams (in a <foreignObject>).

   Structure:
     <div class="cr-brand" data-size="sm|md|lg">
       <img class="cr-brand-logo" src="...">
       <div class="cr-brand-box">
         <span class="cr-brand-reg">&reg;</span>
         <div class="cr-brand-name">Circloud</div>
         <div class="cr-brand-sub"><span>N</span><span>E</span><span>S</span><span>T</span></div>
       </div>
       <div class="cr-brand-slogan">Local Cloud Platform</div>  (optional)
     </div>

   Sizes: sm (header), md (login), lg (nest hero)
*/

.cr-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-family: var(--cr-font-brand, 'Segoe UI', system-ui, -apple-system, sans-serif);
}

/* No part of the lockup is positioned or translucent: either makes that part
   a layer of its own, and WebKit (Safari) paints such a layer inside an SVG
   <foreignObject> without the drawing's scale or transforms — the mark lands
   off its place and unscaled, or vanishes. So the ® is not absolutely placed
   in a relative box: it shares the name's grid cell instead (see
   .cr-brand-reg), at exactly the place top/right gave it. */
.cr-brand-box {
  display: grid;
  grid-template-columns: 1fr;
  width: max-content;
}

.cr-brand-name,
.cr-brand-sub {
  font-weight: 600;
}

.cr-brand-name {
  grid-area: 1 / 1;
  color: var(--text, #fff);
}

.cr-brand-sub {
  grid-area: 2 / 1;
  display: flex;
  justify-content: space-between;
  /* Reads from assets/brand-colors.css — change there to retint everywhere */
  background: var(--nest-brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

.cr-brand-sub span {
  display: inline-block;
}

/* The ® sits in the name's cell, at its end: 0.15em above the box and 0.7em
   past its right edge (the negative margins), so the box keeps the name's
   width. It is first in the markup but second in the cell (order: 1): the
   cell's first item gives the box its baseline, and that stays the name's,
   as when the ® was out of flow — a lockup on a line of text or in a
   baseline-aligned row sits where it did. Half the text colour, as a colour
   rather than opacity: opacity would make it a layer (see .cr-brand-box). */
.cr-brand-reg {
  grid-area: 1 / 1;
  order: 1;
  justify-self: end;
  align-self: start;
  margin: -0.15em -0.7em 0 0;
  font-size: 0.35em;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
  color: color-mix(in srgb, var(--text, #fff) 50%, transparent);
  -webkit-text-fill-color: currentColor;
}

.cr-brand-logo {
  height: auto;
  display: block;
  margin-bottom: 0.3em;
  /* width set by JS to match cr-brand-name width */
}

/* The slogan is text, in the page's text font. */
.cr-brand-slogan {
  font-family: var(--cr-font-sans, 'Segoe UI', system-ui, -apple-system, sans-serif);
  color: #6d7696;
  letter-spacing: 2px;
  text-align: center;
  margin-top: 0.5em;
}

/* ── Size variants ── */

/* sm: header */
.cr-brand[data-size="sm"] {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.cr-brand[data-size="sm"] .cr-brand-logo {
  width: auto;
  height: 42px;
  margin-bottom: 0;
}
.cr-brand[data-size="sm"] .cr-brand-name { font-size: 1.05rem; }
.cr-brand[data-size="sm"] .cr-brand-sub  { font-size: 0.7rem; }
.cr-brand[data-size="sm"] .cr-brand-slogan {
  display: none;
}

/* md: login pages */
.cr-brand[data-size="md"] .cr-brand-name { font-size: 2rem; }
.cr-brand[data-size="md"] .cr-brand-sub  { font-size: 1.3rem; }
.cr-brand[data-size="md"] .cr-brand-slogan {
  font-size: 13px;
}

/* lg: nest hero */
.cr-brand[data-size="lg"] .cr-brand-name { font-size: 3rem; }
.cr-brand[data-size="lg"] .cr-brand-sub  { font-size: 2rem; }
.cr-brand[data-size="lg"] .cr-brand-slogan {
  font-size: 15px;
}
/* Pin the lg logo to a fixed width on every page so the Circloud Nest hero
   logo and the Circloud Portal main logo render at exactly the same size.
   !important wins over the inline width brand.js writes (which only measured
   the brand-box and could differ by a few pixels between pages).
   180px ≈ the natural width of "Circloud" at 3rem 600-weight Segoe UI. */
.cr-brand[data-size="lg"] .cr-brand-logo {
  width: 180px !important;
  height: auto !important;
}
