/* ==========================================================================
   InvnTree Patent Draft Library — InvnTree Design System (navy + cyan)
   ========================================================================== */

/* ---- Fonts ---- */
@font-face { font-family: 'Montserrat'; src: url('../fonts/Montserrat-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('../fonts/Montserrat-Italic.ttf') format('truetype'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('../fonts/Montserrat-Medium.ttf') format('truetype'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('../fonts/Montserrat-SemiBold.ttf') format('truetype'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('../fonts/Montserrat-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('../fonts/Montserrat-ExtraBold.ttf') format('truetype'); font-weight: 800; font-style: normal; font-display: swap; }

/* ---- Tokens ---- */
:root {
  --navy: #282560;
  --navy-hover: #1F1C4D;
  --cyan: #26A7DF;
  --cyan-link: #137CAD;
  --cyan-link-hover: #0D6088;
  --cyan-light: #80CCED;
  --text-body: #5E6680;
  --text-dim: #404863;
  --text-muted: #8C95AC;
  --tint-cyan: #E6F5FC;
  --fill-neutral: #F4F6FA;
  --canvas: #EEF1F6;
  --border: #E8ECF3;
  --border-soft: #F0F2F7;
  --border-btn: #D6DCE7;
  --border-dash: #C9D2E0;
  --footer-tint-1: #C7C4DE;
  --footer-tint-2: #9A95C2;
  --footer-tint-3: #6B65A2;
  --shadow-rest: 0 1px 2px rgba(40,37,96,0.06), 0 1px 1px rgba(40,37,96,0.04);
  --shadow-lift: 0 8px 28px rgba(40,37,96,0.10), 0 2px 6px rgba(40,37,96,0.06);
  --shadow-modal: 0 28px 72px rgba(40,37,96,0.22), 0 6px 16px rgba(40,37,96,0.10);
  --ease-entry: cubic-bezier(0.2, 0.8, 0.2, 1);
  --gutter: clamp(20px, 5vw, 40px);
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background-color: #FFFFFF;
  background-image: radial-gradient(circle, rgba(40,37,96,0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  font-family: Montserrat, system-ui, -apple-system, sans-serif;
  color: var(--navy);
  -webkit-font-smoothing: antialiased;
}
body.scroll-locked { overflow: hidden; }

button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.container { max-width: 1160px; width: 100%; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }

@keyframes ofade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mpop { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 8px; padding: 10px 15px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 200ms, border-color 200ms, color 200ms;
}
.btn-primary { background: var(--navy); color: #fff; border: 1px solid var(--navy); }
.btn-primary:hover { background: var(--navy-hover); border-color: var(--navy-hover); }
.btn-secondary { background: #fff; color: var(--navy); border: 1px solid var(--border-btn); }
.btn-secondary:hover { border-color: var(--cyan); color: var(--cyan-link); }

/* ---- Header ---- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.header-inner .btn { gap: 8px; padding: 10px 18px; font-size: 14px; }

.brand { display: flex; align-items: center; gap: 12px; background: none; border: none; padding: 0; cursor: pointer; }
/* Logo sizing sets height only (from JS) — width stays auto so a
   non-square logo (e.g. a wordmark) keeps its real proportions. Do not
   add a CSS max-width here: capping width while height stays fixed
   distorts the image exactly like the bug this replaced. */
.brand img, .paper-brand img { display: block; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1; text-align: left; }
.brand-name { font-size: 19px; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; }
.brand-name-light { color: #fff; }
.brand-sub { font-size: 12px; font-weight: 500; font-style: italic; color: var(--text-muted); margin-top: 4px; }

/* ---- Main ---- */
.site-main { flex: 1; padding-top: 56px; padding-bottom: 88px; }

/* ---- Home: intro ---- */
.intro { margin-bottom: 44px; max-width: 700px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--cyan); }
.intro h1 {
  font-size: clamp(30px, 4vw, 42px); font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.08; color: var(--navy);
  margin: 14px 0 0;
}
.lede { font-size: 18px; font-style: italic; line-height: 1.6; color: var(--text-body); margin: 18px 0 0; }

/* ---- Home: domain grid ---- */
.domain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 20px; }

.domain-tile {
  text-align: left; background: #fff;
  border: 1px solid var(--border); border-radius: 14px;
  padding: 26px; min-height: 212px;
  cursor: pointer; display: flex; flex-direction: column; gap: 14px;
  color: inherit;
  transition: border-color 200ms, box-shadow 200ms, transform 200ms;
}
.domain-tile:hover {
  border-color: var(--cyan);
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px);
}
.tile-icon {
  width: 52px; height: 52px; border-radius: 12px;
  background: var(--tint-cyan); color: var(--cyan-link);
  display: flex; align-items: center; justify-content: center;
}
.tile-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; color: var(--navy); }
.tile-blurb { font-size: 14px; line-height: 1.5; color: var(--text-body); flex: 1; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.tile-count { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.tile-arrow { color: var(--cyan); display: flex; }

/* ---- Folder: back button + breadcrumb ---- */
.folder-nav {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap; margin-bottom: 26px;
}
.btn-back {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; color: var(--navy);
  border: 1px solid var(--border-btn); border-radius: 8px;
  padding: 9px 15px 9px 12px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: border-color 200ms, color 200ms, box-shadow 200ms, transform 200ms;
}
.btn-back:hover {
  border-color: var(--cyan); color: var(--cyan-link);
  box-shadow: var(--shadow-rest);
}
.btn-back:active { transform: translateX(-1px); }
.btn-back svg { transition: transform 200ms; }
.btn-back:hover svg { transform: translateX(-2px); }

.breadcrumb { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.crumb-link { background: none; border: none; padding: 0; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--cyan-link); }
.crumb-link:hover { color: var(--cyan-link-hover); }
.crumb-sep { color: #B5BDCE; }
.crumb-current { color: var(--text-body); font-weight: 600; }

/* ---- Folder: domain header ---- */
.domain-header {
  display: flex; align-items: center; gap: 20px;
  margin-bottom: 30px; padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.domain-badge {
  width: 60px; height: 60px; border-radius: 14px;
  background: linear-gradient(135deg, #282560 0%, #26A7DF 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: var(--shadow-lift);
}
.domain-header-text { flex: 1; min-width: 0; }
.domain-header-text h1 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 700; letter-spacing: -0.02em; color: var(--navy); margin: 0; }
.domain-header-text p { font-size: 15px; line-height: 1.5; color: var(--text-body); margin: 6px 0 0; max-width: 640px; }
.count-pill {
  align-self: center; background: var(--fill-neutral); color: var(--text-dim);
  padding: 7px 14px; border-radius: 9999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}

/* ---- Folder: file cards ---- */
.file-list { display: flex; flex-direction: column; gap: 14px; max-width: 940px; }

.file-card {
  display: flex; align-items: center; gap: 18px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 22px;
  transition: border-color 200ms, box-shadow 200ms;
}
.file-card:hover { border-color: var(--cyan); box-shadow: var(--shadow-rest); }
.file-chip {
  width: 46px; height: 46px; border-radius: 10px;
  background: var(--fill-neutral); color: var(--navy);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.file-body { flex: 1; min-width: 0; }
.file-tag {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--cyan-link); background: var(--tint-cyan);
  padding: 3px 9px; border-radius: 9999px;
}
.file-title { font-size: 16px; font-weight: 600; color: var(--navy); margin-top: 9px; }
.file-desc { font-size: 13.5px; line-height: 1.5; color: var(--text-body); margin-top: 3px; }
.file-actions { flex-shrink: 0; display: flex; align-items: center; gap: 10px; }

/* ---- Footer ---- */
.site-footer { background: var(--navy); color: #fff; margin-top: auto; }
.footer-inner {
  padding-top: 44px; padding-bottom: 44px;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 28px; flex-wrap: wrap;
}
.footer-brand { cursor: default; }
.footer-tagline { font-style: italic; font-size: 14px; color: var(--footer-tint-1); margin: 14px 0 0; max-width: 380px; }
.footer-right { text-align: right; font-size: 13px; line-height: 1.7; }
.footer-link { color: var(--cyan-light); text-decoration: none; font-weight: 600; }
.footer-line-muted { color: var(--footer-tint-2); margin-top: 6px; }
.footer-line-faint { color: var(--footer-tint-3); margin-top: 2px; }

/* ---- PDF viewer modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16,14,41,0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: clamp(14px, 4vw, 48px);
  z-index: 80;
  animation: ofade 180ms ease-out;
}
.modal-dialog {
  width: min(900px, 100%); max-height: 88vh;
  background: #fff; border-radius: 14px;
  box-shadow: var(--shadow-modal);
  display: flex; flex-direction: column; overflow: hidden;
  animation: mpop 220ms var(--ease-entry);
}
.modal-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px 14px 18px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.toolbar-file { display: flex; align-items: center; gap: 12px; min-width: 0; }
.toolbar-chip {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--fill-neutral); color: var(--navy);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.toolbar-text { min-width: 0; }
.toolbar-title { font-size: 14.5px; font-weight: 600; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar-tag { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.toolbar-actions .btn-primary { padding: 9px 15px; }
.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: var(--text-body);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: background 200ms, color 200ms;
}
.icon-btn:hover { background: var(--fill-neutral); color: var(--navy); }

.modal-canvas {
  flex: 1; overflow: auto; background: var(--canvas);
  padding: clamp(20px, 4vw, 40px);
  display: flex; justify-content: center;
}
.modal-canvas iframe.pdf-frame {
  width: 100%; max-width: 820px; height: 100%; min-height: 60vh;
  border: none; border-radius: 4px; background: #fff;
  box-shadow: 0 8px 28px rgba(40,37,96,0.12);
}

/* ---- Facsimile paper sheet ---- */
.paper {
  width: 100%; max-width: 660px; align-self: flex-start;
  background: #fff; box-shadow: 0 8px 28px rgba(40,37,96,0.12);
  border-radius: 4px; padding: clamp(30px, 5vw, 56px);
}
.paper-brand { display: flex; align-items: center; gap: 10px; }
.paper-brand img { display: block; }
.paper-brand span { font-size: 15px; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; }
.paper-rule { height: 1px; background: var(--border); margin: 22px 0 26px; }
.paper-rule-mid { margin: 26px 0; }
.paper-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--cyan); }
.paper h2 { font-size: clamp(22px, 3.2vw, 28px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.18; color: var(--navy); margin: 12px 0 0; }
.paper-meta { display: flex; flex-wrap: wrap; gap: 22px 36px; margin-top: 22px; }
.meta-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.meta-value { font-size: 13px; color: var(--text-dim); margin-top: 5px; }
.meta-value.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.abstract-label { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--navy); }
.abstract-text { font-size: 14.5px; line-height: 1.7; color: var(--text-dim); margin: 10px 0 0; }
.fig-placeholder {
  margin-top: 28px; height: 200px;
  border: 1px dashed var(--border-dash); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background-color: #FAFBFD;
  background-image: radial-gradient(circle, rgba(40,37,96,0.06) 1px, transparent 1px);
  background-size: 16px 16px;
  color: var(--text-muted);
}
.fig-placeholder .fig-icon { display: flex; }
.fig-caption { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.paper-note { font-size: 12.5px; font-style: italic; line-height: 1.6; color: var(--text-muted); margin: 26px 0 0; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .file-card { flex-wrap: wrap; }
  .file-actions { width: 100%; justify-content: flex-end; }
  .domain-header { flex-wrap: wrap; }
  .footer-right { text-align: left; }
  /* A wide logo at a large size setting would push the header CTA off a
     phone screen. Cap the width and let height follow the aspect ratio
     (height:auto is what keeps it from squashing — never set a fixed
     height alongside max-width here). Overrides the inline height JS sets. */
  .site-header .brand img { max-width: 150px; height: auto !important; }
}
@media (max-width: 380px) {
  .file-actions { flex-wrap: wrap; }
  .file-actions .btn { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal-dialog { animation: none; }
  .domain-tile, .file-card, .btn, .icon-btn, .btn-back, .btn-back svg { transition: none; }
  .domain-tile:hover { transform: none; }
  .btn-back:active, .btn-back:hover svg { transform: none; }
}
