/* =========================================================
   Ruby Programming Language — Modern Redesign
   screen.css · designed for clarity, speed, and elegance
   ========================================================= */

/* ── Custom Properties ─────────────────────────────────── */
:root {
  --ruby:        #CC342D;
  --ruby-dark:   #A82822;
  --ruby-glow:   rgba(204, 52, 45, 0.18);

  --navy:        #1E1B2E;
  --navy-mid:    #16213E;
  --navy-light:  #0F3460;

  --bg:          #FFFFFF;
  --bg-alt:      #F8F9FA;
  --bg-card:     #FFFFFF;

  --text:        #111827;
  --text-muted:  #6B7280;
  --text-light:  #9CA3AF;

  --border:      #E5E7EB;
  --border-mid:  #D1D5DB;

  --code-bg:     #1E1E2E;
  --code-text:   #CDD6F4;
  --code-green:  #A6E3A1;
  --code-yellow: #F9E2AF;
  --code-blue:   #89B4FA;
  --code-red:    #F38BA8;

  --radius-sm:   4px;
  --radius:      8px;
  --radius-lg:   12px;

  --shadow-sm:   0 1px 2px rgba(0,0,0,.06);
  --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:   0 10px 25px -5px rgba(0,0,0,.18), 0 4px 6px -2px rgba(0,0,0,.05);

  --ease:        cubic-bezier(.4,0,.2,1);
  --dur:         160ms;

  --font:        system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  --font-mono:   'SFMono-Regular', Menlo, Consolas, 'Liberation Mono',
                 'Courier New', monospace;

  --max-w:       1200px;
  --sidebar-w:   280px;
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin: 1.5rem 0 .75rem;
}
h1 { font-size: 2.125rem; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.25rem;  }
h4 { font-size: 1.1rem;   }

/* Paragraphs & Lists */
p  { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.5rem; }
li { margin-bottom: .35rem; list-style: revert; }

a {
  color: var(--ruby);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}
a:hover { color: var(--ruby-dark); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

code, pre { font-family: var(--font-mono); font-size: .875em; }

table { border-collapse: collapse; width: 100%; }

/* Utility: hide decorative HRs */
hr.hidden-modern { display: none !important; }

/* ── Page Shell ────────────────────────────────────────── */
#page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header / Nav ──────────────────────────────────────── */
#header {
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
}

#header > * {
  /* center children in header via flex on header itself */
}

/* Inner flex row */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0 clamp(1rem, 4vw, 3rem);
  max-width: var(--max-w);
  margin-inline: auto;
  width: 100%;
}

/* Override: full-width header background */
#header {
  max-width: none;
}

/* Wrapper trick: use pseudo-element or just pad smartly */
/* We'll rely on an inline wrapper */

/* Logo */
#logo {
  padding: .6rem 0;
  flex-shrink: 0;
}
#logo img {
  height: 44px;
  width: auto;
  filter: brightness(0) invert(1);
  transition: opacity var(--dur) var(--ease);
}
#logo a { display: block; }
#logo img:hover { opacity: .85; }

/* Nav links strip */
.site-links {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0;
}
.site-links p { margin: 0; display: contents; }
.site-links .separator { display: none; }

.site-links a {
  display: flex;
  align-items: center;
  color: rgba(255,255,255,.8);
  font-size: .8125rem;
  font-weight: 500;
  letter-spacing: .02em;
  padding: .85rem .9rem;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color var(--dur) var(--ease),
              background var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.site-links a:hover {
  color: #fff;
  background: rgba(255,255,255,.07);
  border-bottom-color: var(--ruby);
  text-decoration: none;
}
.site-links strong a {
  color: var(--ruby) !important;
  border-bottom-color: var(--ruby) !important;
}

/* ── Search Box ────────────────────────────────────────── */
#search-box {
  background: var(--navy-mid);
  border-top: 1px solid rgba(255,255,255,.06);
  padding: .5rem clamp(1rem, 4vw, 3rem);
}
#search-form {
  display: flex;
  max-width: 380px;
  margin-left: auto; /* push to right */
}
/* Reset table layout inside search form */
#search-form table,
#search-form tbody,
#search-form tr,
#search-form td { display: block; width: auto; }
#search-form tr { display: flex; width: 100%; }
#search-form td { padding: 0; }
#search-form td:first-child { flex: 1; }

.field {
  width: 100%;
  padding: .4rem .85rem;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  color: #fff;
  font-size: .875rem;
  outline: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.field::placeholder { color: rgba(255,255,255,.4); }
.field:focus { background: rgba(255,255,255,.15); border-color: var(--ruby); }

.button {
  padding: .4rem 1rem;
  background: var(--ruby);
  color: #fff;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease);
}
.button:hover { background: var(--ruby-dark); }

/* ── Main Content Wrapper ──────────────────────────────── */
#main-wrapper {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding: 2.5rem clamp(1rem, 4vw, 2rem);
}

/* ── Two-Column Grid ───────────────────────────────────── */
#main {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  grid-template-areas:
    "content sidebar"
    "foot    foot";
  gap: 2rem;
  align-items: start;
}

#content-wrapper  { grid-area: content; min-width: 0; }
#sidebar-wrapper  { grid-area: sidebar; }
.foot             { grid-area: foot;    }

/* ── Page Head / Title Area ────────────────────────────── */
#head-wrapper-1,
#head-wrapper-2 { width: 100%; }

#head {
  margin-bottom: 2rem;
}

#head h1 {
  font-size: 2rem;
  margin-top: 0;
  padding-bottom: .5rem;
  border-bottom: 3px solid var(--ruby);
  display: inline-block;
}

/* ── HOME PAGE HERO ────────────────────────────────────── */
body#home-page-layout #head {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 55%, var(--navy-light) 100%);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.5rem;
  display: flex;
  align-items: center;
  gap: 2.5rem;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
  border: none;
}

body#home-page-layout #head::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -5%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, var(--ruby-glow) 0%, transparent 65%);
  pointer-events: none;
}

body#home-page-layout #intro {
  flex: 1;
  color: #fff;
  position: relative;
  z-index: 1;
}

body#home-page-layout #intro h1 {
  color: #fff;
  font-size: 2.6rem;
  margin-top: 0;
  margin-bottom: .75rem;
  border-bottom: none;
  padding-bottom: 0;
  display: block;
  letter-spacing: -.02em;
}

body#home-page-layout #intro p {
  color: rgba(255,255,255,.78);
  font-size: 1.0625rem;
  margin-bottom: 1rem;
  line-height: 1.75;
}

body#home-page-layout #intro a {
  display: inline-block;
  background: var(--ruby);
  color: #fff;
  padding: .6rem 1.6rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .9375rem;
  transition: background var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
  box-shadow: 0 4px 14px rgba(204,52,45,.4);
}
body#home-page-layout #intro a:hover {
  background: var(--ruby-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(204,52,45,.5);
  text-decoration: none;
}

/* Code block (hero) */
#code {
  background: var(--code-bg);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  font-family: var(--font-mono);
  font-size: .8125rem;
  line-height: 1.9;
  min-width: 260px;
  max-width: 310px;
  flex-shrink: 0;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,.05);
  position: relative;
  z-index: 1;
}

/* Fake traffic-light dots */
#code::before {
  content: '● ● ●';
  display: block;
  color: rgba(255,255,255,.25);
  font-size: .5rem;
  letter-spacing: .4rem;
  margin-bottom: .85rem;
}

#code div { display: block; color: var(--code-text); }
#code .blank-line { min-height: 1.3em; }
#code .comment { color: var(--code-green); }
#code .string  { color: var(--code-yellow); }
#code .keyword { color: var(--code-blue); }

/* Code spans inside content */
.comment { color: #22863a; }
.string  { color: #c0392b; }
.keyword { color: #0366d6; }
.caps    { font-size: .9em; letter-spacing: .04em; }

/* ── Content Area ──────────────────────────────────────── */
#content { padding: 0; }

#content h2 {
  border-bottom: 2px solid var(--border);
  padding-bottom: .4rem;
  margin-top: 2rem;
}

#content h3 { margin-top: 1.5rem; }

#content p a,
#content li a { border-bottom: 1px solid var(--ruby-glow); }
#content p a:hover,
#content li a:hover { border-bottom-color: var(--ruby); text-decoration: none; }

#content pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: .8125rem;
  line-height: 1.8;
  box-shadow: var(--shadow);
}

#content code:not(pre code) {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .15rem .4rem;
  color: var(--ruby);
  font-size: .85em;
}

#content blockquote {
  border-left: 4px solid var(--ruby);
  margin: 1.5rem 0;
  padding: .75rem 1.25rem;
  background: var(--bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
}

#content table {
  margin: 1.5rem 0;
  font-size: .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
#content th {
  background: var(--navy);
  color: #fff;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .7rem 1rem;
  text-align: left;
}
#content td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
}
#content tr:last-child td { border-bottom: none; }
#content tr:nth-child(even) td { background: var(--bg-alt); }

/* News posts */
.post {
  padding-bottom: 1.75rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}
.post:last-of-type { border-bottom: none; }

.post h3 {
  margin-top: 0;
  margin-bottom: .4rem;
  font-size: 1.125rem;
}
.post h3 a {
  color: var(--text);
  transition: color var(--dur) var(--ease);
}
.post h3 a:hover { color: var(--ruby); text-decoration: none; }

.post-info {
  font-size: .775rem;
  color: var(--text-muted);
  display: block;
  margin-top: .35rem;
}

.post p:last-of-type a {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--ruby);
}
.post p:last-of-type a:hover { text-decoration: underline; }

/* News index section */
#news {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-top: 2rem;
}
#news h3 { margin-top: 0; margin-bottom: 1rem; }
#news ul {
  list-style: none;
  padding: 0;
  margin: 0 0 .5rem;
}
#news ul li {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
#news ul li:last-child { border-bottom: none; }
#news ul li a { font-weight: 600; flex: 1; color: var(--text); }
#news ul li a:hover { color: var(--ruby); text-decoration: none; }
#news ul li .post-info { white-space: nowrap; margin: 0; }

.more { text-align: right; margin-top: .75rem; }
.more a {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--ruby);
  display: inline-flex;
  align-items: center;
  gap: .2rem;
}

/* ── Sidebar ───────────────────────────────────────────── */
#sidebar {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: sticky;
  top: 5rem; /* below sticky header */
  box-shadow: var(--shadow-sm);
}

#sidebar .navigation {
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
#sidebar .navigation:last-of-type {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

#sidebar h3 {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: .6rem;
}

#sidebar strong { color: var(--text); }

#sidebar ul.menu,
#sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
#sidebar ul.menu li,
#sidebar ul li {
  margin: 0;
  list-style: none;
  border-bottom: 1px solid var(--border);
}
#sidebar ul.menu li:last-child,
#sidebar ul li:last-child { border-bottom: none; }

#sidebar ul.menu li a,
#sidebar ul li a {
  display: block;
  padding: .4rem 0;
  color: var(--text);
  font-size: .875rem;
  transition: color var(--dur) var(--ease);
}
#sidebar ul.menu li a:hover,
#sidebar ul li a:hover {
  color: var(--ruby);
  text-decoration: none;
}

/* Download image in sidebar */
#sidebar .navigation > a { display: block; text-align: center; }
#sidebar .navigation > a > img {
  max-width: 160px;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

/* Syndicate / RSS */
#sidebar p.more { text-align: left; }

/* ── Footer Nav Strip ──────────────────────────────────── */
.foot {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  margin-top: .5rem;
}
.foot .site-links {
  flex-wrap: wrap;
  justify-content: center;
}
.foot .site-links a {
  color: var(--text-muted);
  font-size: .8125rem;
  padding: .3rem .6rem;
  border-bottom: none;
}
.foot .site-links a:hover {
  color: var(--ruby);
  background: none;
  border-bottom: none;
  text-decoration: none;
}
.foot .site-links p { display: contents; margin: 0; }
.foot .site-links .separator { display: none; }
.foot .site-links strong a { color: var(--ruby); }

/* ── Footer ────────────────────────────────────────────── */
#footer {
  background: var(--navy);
  color: rgba(255,255,255,.65);
  margin-top: 0;
}

#footer .fine-print {
  max-width: var(--max-w);
  margin-inline: auto;
  padding: 2rem clamp(1rem, 4vw, 2rem);
  font-size: .8125rem;
  line-height: 1.75;
}
#footer .fine-print p { margin-bottom: .5rem; }
#footer .fine-print p:last-child { margin-bottom: 0; }
#footer .fine-print a { color: rgba(255,255,255,.8); }
#footer .fine-print a:hover { color: #fff; text-decoration: underline; }

/* ── Inner Page Specifics ──────────────────────────────── */

/* Fieldset / form tables on misc pages */
.fieldset { width: 100%; }
table.fieldset td { padding: .25rem; }

/* Extended content div used in news articles */
#extended { margin-top: 1rem; }

/* External link indicator */
#content a[href^="http"]:not([href*="ruby-lang"]):not([href*="plesk.com"]):not([href*="rubyidentity"]):not([href*="radiantcms"]):not([href*="amazon.com"])::after {
  content: '↗';
  font-size: .7em;
  margin-left: .15em;
  vertical-align: top;
  opacity: .6;
}

/* ── Quick-start / Tutorial Sections ──────────────────── */
#content ol li { margin-bottom: .75rem; }
#content ol li p { margin-bottom: .4rem; }

/* Numbered navigation (quickstart) */
#content p a[href$="/1/"],
#content p a[href$="/2/"],
#content p a[href$="/3/"],
#content p a[href$="/4/"],
#content p a[href*="quickstart"] {
  display: inline-block;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .25rem .65rem;
  font-weight: 600;
  margin: .1rem;
  color: var(--text);
}
#content p a[href$="/1/"]:hover,
#content p a[href$="/2/"]:hover,
#content p a[href$="/3/"]:hover,
#content p a[href$="/4/"]:hover { border-color: var(--ruby); color: var(--ruby); text-decoration: none; }

/* ── Language-specific tweaks ──────────────────────────── */
/* Japanese / CJK: slightly looser spacing */
:lang(ja) body,
:lang(zh) body,
:lang(ko) body {
  line-height: 1.8;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
}

@media (max-width: 720px) {
  #main {
    grid-template-columns: 1fr;
    grid-template-areas:
      "content"
      "sidebar"
      "foot";
  }

  #sidebar { position: static; }

  body#home-page-layout #head {
    flex-direction: column;
    padding: 2rem 1.5rem;
  }

  #code {
    max-width: 100%;
    min-width: unset;
    width: 100%;
  }

  body#home-page-layout #intro h1 { font-size: 1.9rem; }

  .site-links {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  #header {
    padding: 0 1rem;
  }

  #main-wrapper { padding: 1.25rem 1rem; }

  #head h1 { font-size: 1.625rem; }

  #search-form { max-width: 100%; }
  #search-box { padding: .5rem 1rem; }
}

@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  body#home-page-layout #intro h1 { font-size: 1.6rem; }
  #logo img { height: 36px; }
  .site-links a { padding: .75rem .65rem; font-size: .75rem; }
}

/* ── Focus / Accessibility ─────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--ruby);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Skip-nav (if ever present) */
.skip-nav {
  position: absolute;
  left: -9999px;
}
.skip-nav:focus {
  left: 1rem;
  top: 1rem;
  background: var(--ruby);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  z-index: 9999;
}

/* ── Scrollbar styling (optional, Webkit) ──────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
