/* ===================================================================
   Ubuntu Portal — Custom Theme Stylesheet
   A modern Linux publication design with split-grid layout
   =================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg: #0d1117;
  --c-surface: #161b22;
  --c-surface-raised: #1c2129;
  --c-border: #30363d;
  --c-text: #e6edf3;
  --c-text-muted: #8b949e;
  --c-text-subtle: #6e7681;
  --c-accent: #e95420;
  --c-accent-hover: #ff6b3d;
  --c-link: #58a6ff;
  --c-link-hover: #79c0ff;
  --c-green: #3fb950;
  --c-yellow: #d29922;
  --c-red: #f85149;
  --c-purple: #bc8cff;

  --font-heading: Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  --rail-w: 240px;
  --sidebar-w: 260px;
  --header-h: 60px;
  --max-content: 1400px;
  --radius: 8px;
  --radius-sm: 4px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-link); text-decoration: none; transition: color .15s; }
a:hover { color: var(--c-link-hover); }

img { max-width: 100%; height: auto; display: block; }

/* --- Typography (prose) --- */
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--font-heading); color: var(--c-text); margin: 1.8em 0 .6em; line-height: 1.3; }
.prose h1 { font-size: 2.2rem; }
.prose h2 { font-size: 1.6rem; border-bottom: 1px solid var(--c-border); padding-bottom: .3em; }
.prose h3 { font-size: 1.3rem; }
.prose h4 { font-size: 1.1rem; }
.prose p { margin: 0 0 1.2em; }
.prose ul, .prose ol { margin: 0 0 1.2em 1.5em; }
.prose li { margin-bottom: .4em; }
.prose blockquote { border-left: 4px solid var(--c-accent); padding: .8em 1.2em; margin: 1.2em 0; background: var(--c-surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prose code { font-family: var(--font-mono); font-size: .9em; background: var(--c-surface-raised); padding: .15em .4em; border-radius: var(--radius-sm); }
.prose pre { background: var(--c-surface); padding: 1.2em; border-radius: var(--radius); overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--c-border); }
.prose pre code { background: none; padding: 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.2em 0; }
.prose th, .prose td { padding: .6em .8em; border: 1px solid var(--c-border); text-align: left; }
.prose th { background: var(--c-surface); font-weight: 600; }
.prose hr { border: none; border-top: 1px solid var(--c-border); margin: 2em 0; }

/* --- Site Header --- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  height: var(--header-h);
}
.site-header__inner {
  max-width: var(--max-content); margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem; height: 100%;
}
.site-logo { display: flex; align-items: center; gap: .5rem; color: var(--c-text); font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.site-logo:hover { color: var(--c-accent); }
.site-logo__mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--c-accent); color: #fff; font-weight: 800; font-size: .85rem;
}
.site-nav { flex: 1; }
.nav-menu { list-style: none; display: flex; gap: .2rem; margin: 0; padding: 0; }
.nav-menu__link {
  display: block; padding: .5rem .75rem; border-radius: var(--radius-sm);
  color: var(--c-text-muted); font-size: .9rem; font-weight: 500; transition: background .15s, color .15s;
}
.nav-menu__link:hover, .nav-menu__link.is-active { color: var(--c-text); background: var(--c-surface-raised); }

.site-header__actions { display: flex; align-items: center; gap: .75rem; }
.search-btn {
  background: none; border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  color: var(--c-text-muted); padding: .4rem; cursor: pointer; display: flex; align-items: center;
  transition: border-color .15s, color .15s;
}
.search-btn:hover { border-color: var(--c-text-muted); color: var(--c-text); }
.header-quick-link {
  font-size: .85rem; padding: .4rem .75rem; border-radius: var(--radius-sm);
  background: var(--c-accent); color: #fff; font-weight: 600; transition: background .15s;
}
.header-quick-link:hover { background: var(--c-accent-hover); color: #fff; }

.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: .5rem; }
.nav-toggle__bar { display: block; width: 22px; height: 2px; background: var(--c-text); margin: 4px 0; border-radius: 2px; }

/* --- Grid Layout --- */
.site-grid {
  max-width: var(--max-content); margin: 0 auto;
  display: grid;
  grid-template-columns: var(--rail-w) 1fr var(--sidebar-w);
  gap: 0;
  min-height: calc(100vh - var(--header-h));
}
.rail {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; border-right: 1px solid var(--c-border);
  padding: 1.5rem 1rem;
}
.content { padding: 2rem 2.5rem; min-width: 0; }
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; border-left: 1px solid var(--c-border);
  padding: 1.5rem 1rem;
}

/* --- Rail Nav --- */
.rail__heading { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--c-text-subtle); margin-bottom: .6rem; font-family: var(--font-body); }
.rail__list { list-style: none; }
.rail__link {
  display: block; padding: .45rem .6rem; border-radius: var(--radius-sm);
  color: var(--c-text-muted); font-size: .9rem; transition: background .15s, color .15s;
}
.rail__link:hover, .rail__link.is-active { background: var(--c-surface-raised); color: var(--c-text); }
.rail__toc { font-size: .85rem; }
.rail__toc ul { list-style: none; padding-left: .8rem; }
.rail__toc a { color: var(--c-text-muted); display: block; padding: .25rem 0; }
.rail__toc a:hover { color: var(--c-link); }

/* --- Sidebar --- */
.sidebar__widget { margin-bottom: 2rem; }
.sidebar__title { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--c-text-subtle); margin-bottom: .6rem; }
.sidebar__actions { list-style: none; }
.sidebar__action { display: block; padding: .4rem .6rem; border-radius: var(--radius-sm); color: var(--c-text-muted); font-size: .85rem; }
.sidebar__action:hover { background: var(--c-surface-raised); color: var(--c-text); }
.sidebar__links { list-style: none; font-size: .85rem; }
.sidebar__links li { margin-bottom: .3rem; }
.sidebar__links a { color: var(--c-text-muted); }
.sidebar__links a:hover { color: var(--c-link); }
.sidebar__compat { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; }
.compat-badge {
  font-size: .75rem; padding: .2rem .5rem; border-radius: var(--radius-sm);
  background: var(--c-surface-raised); color: var(--c-text-muted); border: 1px solid var(--c-border);
}

/* --- Article --- */
.article__header { margin-bottom: 2rem; }
.article__hero { border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.article__hero img { width: 100%; height: auto; }
.article__title { font-family: var(--font-heading); font-size: 2.2rem; line-height: 1.2; margin-bottom: .5rem; }
.article__desc { font-size: 1.15rem; color: var(--c-text-muted); line-height: 1.5; }
.article__meta { font-size: .85rem; color: var(--c-text-subtle); margin-top: .5rem; }
.tag { padding: .15em .5em; border-radius: var(--radius-sm); background: var(--c-surface-raised); color: var(--c-text-muted); font-size: .8rem; }
.tag:hover { color: var(--c-link); }

/* --- Compatibility Strip --- */
.compat-strip { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; padding: .8rem 1rem; background: var(--c-surface); border-radius: var(--radius); border: 1px solid var(--c-border); }
.compat-strip__label { font-size: .8rem; color: var(--c-text-subtle); font-weight: 600; }
.compat-strip__badge { font-size: .8rem; padding: .2rem .6rem; border-radius: 12px; background: rgba(233,84,32,.15); color: var(--c-accent); font-weight: 500; }

/* --- Command Card --- */
.command-card { margin: 1.5em 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--c-border); background: var(--c-surface); }
.command-card__chrome {
  display: flex; align-items: center; gap: .4rem; padding: .6rem 1rem;
  background: var(--c-surface-raised); border-bottom: 1px solid var(--c-border);
}
.command-card__dot { width: 12px; height: 12px; border-radius: 50%; }
.command-card__dot--red { background: var(--c-red); }
.command-card__dot--yellow { background: var(--c-yellow); }
.command-card__dot--green { background: var(--c-green); }
.command-card__title { flex: 1; font-size: .8rem; color: var(--c-text-muted); margin-left: .5rem; }
.command-card__copy {
  font-size: .75rem; padding: .2rem .6rem; border-radius: var(--radius-sm);
  background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text-muted);
  cursor: pointer; transition: color .15s, border-color .15s;
}
.command-card__copy:hover { color: var(--c-text); border-color: var(--c-text-muted); }
.command-card__body { padding: 1rem 1.2rem; margin: 0; font-family: var(--font-mono); font-size: .9rem; line-height: 1.6; overflow-x: auto; border: none; background: none; }
.command-card__body code { background: none; padding: 0; }

/* --- Cards --- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1rem; }
.card {
  display: block; background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); overflow: hidden; transition: border-color .15s, transform .1s;
}
.card:hover { border-color: var(--c-accent); transform: translateY(-2px); color: var(--c-text); }
.card__img { width: 100%; height: 160px; object-fit: cover; }
.card__body { padding: 1rem 1.2rem; }
.card__title { font-family: var(--font-heading); font-size: 1.1rem; margin-bottom: .3rem; color: var(--c-text); }
.card__desc { font-size: .85rem; color: var(--c-text-muted); line-height: 1.5; }

/* --- Section Hub --- */
.section-hub__header { margin-bottom: 2rem; }
.section-hub__hero { border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.section-hub__title { font-family: var(--font-heading); font-size: 2rem; }
.section-hub__desc { font-size: 1.1rem; color: var(--c-text-muted); margin-top: .5rem; }

/* --- Home Page --- */
.hero {
  text-align: center; padding: 3rem 1rem 2rem;
  background: linear-gradient(135deg, var(--c-surface) 0%, rgba(233,84,32,.08) 100%);
  border-radius: var(--radius); margin-bottom: 2rem;
  border: 1px solid var(--c-border);
}
.hero__title { font-family: var(--font-heading); font-size: 2.8rem; margin-bottom: .5rem; }
.hero__tagline { font-size: 1.2rem; color: var(--c-text-muted); margin-bottom: 1.5rem; }
.hero__search { max-width: 520px; margin: 0 auto; }

.cmd-palette-trigger {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .7rem 1rem; border-radius: var(--radius);
  background: var(--c-surface-raised); border: 1px solid var(--c-border);
  color: var(--c-text-muted); cursor: pointer; font-size: .95rem; transition: border-color .15s;
}
.cmd-palette-trigger:hover { border-color: var(--c-text-subtle); }
.cmd-palette-trigger__icon { font-size: 1.1rem; }
.cmd-palette-trigger__text { flex: 1; text-align: left; }
.cmd-palette-trigger__kbd { font-size: .75rem; padding: .15em .4em; border-radius: var(--radius-sm); border: 1px solid var(--c-border); background: var(--c-surface); }

/* --- Tile Grid --- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }
.tile {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 1.5rem 1rem; border-radius: var(--radius);
  background: var(--c-surface); border: 1px solid var(--c-border);
  transition: border-color .15s, transform .1s;
}
.tile:hover { border-color: var(--c-accent); transform: translateY(-2px); color: var(--c-text); }
.tile__icon { font-size: 2rem; margin-bottom: .5rem; }
.tile__label { font-family: var(--font-heading); font-size: 1.15rem; font-weight: 600; margin-bottom: .3rem; color: var(--c-text); }
.tile__desc { font-size: .8rem; color: var(--c-text-muted); }

/* --- Browse sections --- */
.browse-sections { margin: 2.5rem 0; }
.browse-sections h2 { font-family: var(--font-heading); font-size: 1.5rem; margin-bottom: 1rem; }

.recent-updates { margin: 2.5rem 0; }
.recent-updates h2 { font-family: var(--font-heading); font-size: 1.5rem; margin-bottom: 1rem; }

/* --- FAQ --- */
.faq { margin: 2.5rem 0; }
.faq h2 { font-family: var(--font-heading); font-size: 1.5rem; margin-bottom: 1rem; }
.faq__item { margin-bottom: .5rem; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.faq__item summary { padding: .8rem 1rem; cursor: pointer; font-weight: 600; background: var(--c-surface); }
.faq__item summary:hover { background: var(--c-surface-raised); }
.faq__answer { padding: .8rem 1rem; border-top: 1px solid var(--c-border); }

/* --- Related Reading --- */
.related-reading { margin: 2.5rem 0; padding: 1.5rem; background: var(--c-surface); border-radius: var(--radius); border: 1px solid var(--c-border); }
.related-reading h2 { font-family: var(--font-heading); font-size: 1.2rem; margin-bottom: .8rem; }
.related-reading ul { list-style: none; }
.related-reading li { margin-bottom: .4rem; }
.related-reading a { color: var(--c-link); font-size: .95rem; }

/* --- Taxonomy --- */
.taxonomy-page { margin-bottom: 2rem; }
.taxonomy-page h1 { font-family: var(--font-heading); font-size: 2rem; margin-bottom: 1rem; }
.term-list { list-style: none; columns: 2; gap: 1rem; }
.term-list li { break-inside: avoid; margin-bottom: .4rem; }
.term-count { color: var(--c-text-subtle); font-size: .85rem; }

/* --- Error page --- */
.error-page { text-align: center; padding: 4rem 1rem; }
.error-page__code { font-size: 6rem; font-family: var(--font-heading); color: var(--c-accent); line-height: 1; }
.error-page__message { font-size: 1.4rem; margin: 1rem 0 .5rem; }
.error-page__hint { color: var(--c-text-muted); margin-bottom: 2rem; }
.error-page__actions { display: flex; justify-content: center; gap: 1rem; margin-bottom: 2rem; }
.error-page__search { max-width: 400px; margin: 0 auto; }

/* --- Buttons --- */
.btn { display: inline-block; padding: .6rem 1.2rem; border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; transition: background .15s, color .15s; }
.btn--primary { background: var(--c-accent); color: #fff; }
.btn--primary:hover { background: var(--c-accent-hover); color: #fff; }
.btn--outline { background: transparent; border: 1px solid var(--c-border); color: var(--c-text-muted); }
.btn--outline:hover { border-color: var(--c-text-muted); color: var(--c-text); }

/* --- Command Palette Overlay --- */
.cmd-palette { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding-top: 15vh; }
.cmd-palette[hidden] { display: none; }
.cmd-palette__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.cmd-palette__body { position: relative; width: 90%; max-width: 600px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: 0 16px 48px rgba(0,0,0,.4); }
.cmd-palette__input-wrap { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-bottom: 1px solid var(--c-border); }
.cmd-palette__input-wrap svg { color: var(--c-text-muted); flex-shrink: 0; }
.cmd-palette__input { flex: 1; background: none; border: none; color: var(--c-text); font-size: 1rem; outline: none; font-family: var(--font-body); }
.cmd-palette__esc { font-size: .7rem; padding: .15em .4em; border-radius: var(--radius-sm); border: 1px solid var(--c-border); color: var(--c-text-subtle); }
.cmd-palette__results { padding: 1rem; max-height: 50vh; overflow-y: auto; }
.cmd-palette__hint { color: var(--c-text-subtle); font-size: .9rem; text-align: center; }

/* --- Footer --- */
.site-footer { border-top: 1px solid var(--c-border); padding: 2rem 1.5rem; margin-top: 3rem; }
.site-footer__inner { max-width: var(--max-content); margin: 0 auto; text-align: center; }
.site-footer__brand { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-bottom: 1rem; }
.site-footer__tagline { color: var(--c-text-muted); font-size: .9rem; }
.footer-links { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.footer-links a { color: var(--c-text-muted); font-size: .85rem; }
.footer-links a:hover { color: var(--c-text); }
.site-footer__copy { font-size: .8rem; color: var(--c-text-subtle); }
.site-footer__note { font-size: .75rem; color: var(--c-text-subtle); margin-top: .3rem; }

/* --- Mobile Bottom Nav --- */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  background: var(--c-surface); border-top: 1px solid var(--c-border);
  justify-content: space-around; padding: .4rem 0;
}
.mobile-nav__item { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .3rem .5rem; color: var(--c-text-muted); font-size: .7rem; text-decoration: none; background: none; border: none; cursor: pointer; }
.mobile-nav__icon { font-size: 1.2rem; }

/* --- Responsive --- */
@media (max-width: 1100px) {
  .sidebar { display: none; }
  .site-grid { grid-template-columns: var(--rail-w) 1fr; }
}
@media (max-width: 768px) {
  .rail { display: none; }
  .site-grid { grid-template-columns: 1fr; }
  .content { padding: 1.5rem 1rem; }
  .nav-menu { display: none; }
  .nav-toggle { display: block; }
  .nav-menu.is-open { display: flex; flex-direction: column; position: absolute; top: var(--header-h); left: 0; right: 0; background: var(--c-surface); border-bottom: 1px solid var(--c-border); padding: 1rem; z-index: 50; }
  .mobile-nav { display: flex; }
  body { padding-bottom: 60px; }
  .hero__title { font-size: 2rem; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .card-grid { grid-template-columns: 1fr; }
  .header-quick-link { display: none; }
  .term-list { columns: 1; }
}
