/* ============================================================
   Java Tutorial — Modern Redesign
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  --clr-primary:   #1b2a47;   /* deep navy */
  --clr-accent:    #e84c3d;   /* Java red */
  --clr-accent2:   #f07c35;   /* warm orange */
  --clr-bg:        #f5f6f8;
  --clr-surface:   #ffffff;
  --clr-border:    #e0e4ec;
  --clr-text:      #2c3345;
  --clr-muted:     #6b7585;
  --clr-code-bg:   #1e2433;
  --clr-code-text: #abb2bf;

  --radius:        6px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.10);
  --transition:    0.2s ease;

  --sidebar-w:     240px;
  --max-w:         1140px;
  --font-stack:    'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:     'Cascadia Code', 'Fira Code', Consolas, 'Courier New', monospace;
}

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-stack);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--clr-accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--clr-accent2); }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4, h5, h6 {
  color: var(--clr-primary);
  line-height: 1.3;
  font-weight: 700;
}

h1 { font-size: 1.85rem; margin-bottom: .75rem; }
h2 { font-size: 1.35rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1.1rem;  margin: 1.25rem 0 .4rem; }

p  { margin-bottom: .9rem; }
ul, ol { padding-left: 1.4rem; margin-bottom: .9rem; }
li { margin-bottom: .25rem; }

strong { font-weight: 600; }
em     { font-style: italic; }

/* ── Skip link ─────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -999px;
  left: 1rem;
  background: var(--clr-accent);
  color: #fff;
  padding: .4rem .8rem;
  border-radius: var(--radius);
  z-index: 9999;
}
.skip-link:focus { top: .5rem; }

/* ── Site Header ────────────────────────────────────────────── */
.site-header {
  background: var(--clr-primary);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 60px;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
  text-decoration: none;
}
.site-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--clr-accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -.05em;
}
.site-logo .logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.site-logo:hover .logo-text { color: #e0e4f0; }

/* Primary Nav */
.primary-nav { flex: 1; }
.primary-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: .25rem;
}
.primary-nav a {
  display: block;
  padding: .4rem .75rem;
  color: rgba(255,255,255,.85);
  font-size: .88rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.primary-nav a:hover,
.primary-nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.primary-nav li.active > a { background: var(--clr-accent); color: #fff; }

/* Search */
.header-search {
  flex-shrink: 0;
}
.header-search form {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px;
  overflow: hidden;
  transition: background var(--transition);
}
.header-search form:focus-within {
  background: rgba(255,255,255,.2);
}
.header-search input[type="search"],
.header-search input[type="text"] {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  padding: .35rem .75rem;
  font-size: .88rem;
  width: 160px;
}
.header-search input::placeholder { color: rgba(255,255,255,.55); }
.header-search button {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  padding: .35rem .6rem;
  font-size: .95rem;
}

/* Hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: .25rem;
  margin-left: auto;
}
.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Page layout ────────────────────────────────────────────── */
.page-wrap {
  max-width: var(--max-w);
  margin: 1.5rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 1.5rem;
  flex: 1;
  align-items: start;
}

/* home page has an optional right sidebar */
.page-wrap.has-right { grid-template-columns: var(--sidebar-w) 1fr 220px; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 1rem; }

.widget {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.widget-title {
  background: var(--clr-primary);
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .55rem .9rem;
  margin: 0;
}

.widget-body { padding: .6rem 0; }

.widget-body ul { list-style: none; padding: 0; margin: 0; }
.widget-body li a {
  display: block;
  padding: .4rem .9rem;
  font-size: .88rem;
  color: var(--clr-text);
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.widget-body li a:hover {
  background: #f0f3fa;
  border-color: var(--clr-accent);
  color: var(--clr-accent);
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow-sm);
  min-width: 0; /* prevent overflow in grid */
}

/* ── Latest News / Popular ──────────────────────────────────── */
.home-modules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.news-module {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.news-module-title {
  background: linear-gradient(135deg, var(--clr-primary), #2c4070);
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .55rem .9rem;
  margin: 0;
}
.news-module ul { list-style: none; padding: 0; margin: 0; }
.news-module li { border-bottom: 1px solid var(--clr-border); }
.news-module li:last-child { border-bottom: none; }
.news-module li a {
  display: block;
  padding: .5rem .9rem;
  font-size: .87rem;
  color: var(--clr-text);
  transition: background var(--transition), color var(--transition);
}
.news-module li a:hover {
  background: #f0f3fa;
  color: var(--clr-accent);
}

/* ── Article header ─────────────────────────────────────────── */
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.2rem;
  font-size: .82rem;
  color: var(--clr-muted);
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--clr-border);
  align-items: center;
}
.article-meta .badge {
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: 20px;
  padding: .15rem .65rem;
  font-size: .78rem;
}

/* ── Category Table ─────────────────────────────────────────── */
.category-description {
  background: #f0f4fb;
  border-left: 4px solid var(--clr-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .9rem 1.1rem;
  margin-bottom: 1.5rem;
  font-size: .93rem;
}

.category-description img { display: inline; max-height: 1em; vertical-align: middle; }

.article-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.article-table thead th {
  background: var(--clr-primary);
  color: #fff;
  padding: .55rem .9rem;
  text-align: left;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.article-table thead th:last-child { text-align: center; width: 80px; }
.article-table tbody tr { transition: background var(--transition); }
.article-table tbody tr:nth-child(odd)  { background: #f8f9fc; }
.article-table tbody tr:nth-child(even) { background: var(--clr-surface); }
.article-table tbody tr:hover { background: #e8edf8; }
.article-table td {
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--clr-border);
  vertical-align: top;
}
.article-table td.num { color: var(--clr-muted); font-size: .82rem; width: 36px; }
.article-table td.hits { text-align: center; color: var(--clr-muted); font-size: .82rem; }
.article-table a { color: var(--clr-text); font-weight: 500; }
.article-table a:hover { color: var(--clr-accent); }

/* ── Category grid (home page subjects) ─────────────────────── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 1rem 0;
}
.category-card {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--clr-surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.category-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.category-card a { text-decoration: none; color: inherit; display: block; }
.category-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-bottom: 1px solid var(--clr-border);
}
.category-card-body { padding: .8rem; }
.category-card h3 {
  font-size: .95rem;
  margin: 0 0 .35rem;
  color: var(--clr-primary);
}
.category-card p {
  font-size: .83rem;
  color: var(--clr-muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Code Blocks ────────────────────────────────────────────── */
pre, pre[class*="brush:"], pre[class*="language-"] {
  background: var(--clr-code-bg) !important;
  color: var(--clr-code-text) !important;
  border-radius: var(--radius) !important;
  padding: 1.1rem 1.25rem !important;
  overflow-x: auto;
  font-family: var(--font-mono) !important;
  font-size: .88rem !important;
  line-height: 1.65 !important;
  margin: 1rem 0 !important;
  border: none !important;
  box-shadow: var(--shadow-md);
}

code {
  background: #eef0f7;
  color: #c0392b;
  border-radius: 3px;
  padding: .1em .35em;
  font-family: var(--font-mono);
  font-size: .88em;
}

pre code {
  background: transparent !important;
  color: inherit !important;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* SyntaxHighlighter compatibility */
.syntaxhighlighter,
.syntaxhighlighter table { background: var(--clr-code-bg) !important; }
.syntaxhighlighter .line { background: transparent !important; }
.syntaxhighlighter .gutter { background: #161b27 !important; border-right: 1px solid #2e3650 !important; }
.syntaxhighlighter .gutter .line { color: #4a5270 !important; }
.syntaxhighlighter .toolbar { display: none !important; }
.syntaxhighlighter .keyword { color: #c678dd !important; }
.syntaxhighlighter .string  { color: #98c379 !important; }
.syntaxhighlighter .comment { color: #7f848e !important; font-style: italic !important; }
.syntaxhighlighter .number  { color: #d19a66 !important; }

/* ── Blockquotes ────────────────────────────────────────────── */
blockquote {
  border-left: 4px solid var(--clr-accent2);
  background: #fff8f0;
  padding: .8rem 1.1rem;
  margin: 1rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: #5a4535;
}

/* ── Callout boxes (from typography.css classes) ────────────── */
.important, .notice, .alert, .download, .information {
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin: 1rem 0;
  font-size: .92rem;
  border-left: 4px solid;
}
.important   { background: #fff3cd; border-color: #f0ad4e; color: #5a4000; }
.alert       { background: #f8d7da; border-color: var(--clr-accent); color: #721c24; }
.notice      { background: #d1ecf1; border-color: #17a2b8; color: #0c5460; }
.download    { background: #d4edda; border-color: #28a745; color: #155724; }
.information { background: #e8eaf6; border-color: #3f51b5; color: #1a237e; }

/* ── Tables (article content) ───────────────────────────────── */
.main-content table:not(.article-table) {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: .9rem;
}
.main-content table:not(.article-table) th {
  background: var(--clr-primary);
  color: #fff;
  padding: .5rem .75rem;
  text-align: left;
}
.main-content table:not(.article-table) td {
  padding: .5rem .75rem;
  border: 1px solid var(--clr-border);
}
.main-content table:not(.article-table) tr:nth-child(odd) td { background: #f8f9fc; }

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb {
  font-size: .82rem;
  color: var(--clr-muted);
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
}
.breadcrumb a { color: var(--clr-muted); }
.breadcrumb a:hover { color: var(--clr-accent); }
.breadcrumb .sep { color: var(--clr-border); }
.breadcrumb .current { color: var(--clr-text); font-weight: 500; }

/* ── Right column (home only) ───────────────────────────────── */
.right-col { display: flex; flex-direction: column; gap: 1rem; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  background: var(--clr-primary);
  color: rgba(255,255,255,.7);
  margin-top: auto;
  padding: 1.5rem 1rem;
  font-size: .85rem;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
}
.footer-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.footer-links a { color: rgba(255,255,255,.65); font-size: .83rem; }
.footer-links a:hover { color: #fff; }
.footer-copy { font-size: .82rem; text-align: right; }

/* ── Utility ────────────────────────────────────────────────── */
.clr { clear: both; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* hide Joomla cruft that may survive in content */
.buttonheading,
.joomla_add_this,
.login-links,
.side-mod-bottom,
.close-handle,
.tools-handle,
.filter,
.display,
#accessibility,
.date-block,
#top-bar,
.side-shadow-l,
.side-shadow-r,
#top-divider,
#logo-bg-area,
#logo-surround,
#logo-banner,
#header-tools,
#horiz-menu.splitmenu,
#page-bg > .wrapper > .side-shadow-l,
.bottom-expansion,
.footer-bar,
#footer-bar > #clear-cookies,
.leading_separator,
.article-extras,
h2.contentheading:empty,
.content-header { display: none !important; }

/* Flatten Joomla frontpage article wrappers */
.frontpage-item,
.frontpage-item-bg,
.content-padding,
.blog,
.leading,
.content-tools { display: contents; }

/* Leading article extras (dates on home page) */
.iteminfo { display: none !important; }

/* avatar image cleanup */
.avatar_left {
  float: left;
  margin: 0 1rem .75rem 0;
  border-radius: 50%;
  border: 2px solid var(--clr-border) !important;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .page-wrap,
  .page-wrap.has-right {
    grid-template-columns: 1fr;
  }
  .sidebar { order: 2; }
  .main-content { order: 1; }
  .right-col { order: 3; }

  .home-modules { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 700px) {
  .nav-toggle { display: flex; }

  .primary-nav,
  .header-search { display: none; }

  .primary-nav.open {
    display: block;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--clr-primary);
    padding: .75rem 1rem 1rem;
    box-shadow: var(--shadow-md);
    z-index: 199;
  }
  .primary-nav.open ul { flex-direction: column; }
  .primary-nav.open a { padding: .6rem .75rem; font-size: .95rem; }

  .main-content { padding: 1.2rem 1rem; }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.15rem; }
}
