/* ===== VARIABLES & RESET ===== */
:root {
  --primary-bg: #223033;
  --secondary-bg: #1d2224;
  --text-color: #fff;
  --accent-color: #227777;
  --link-color: #CC66bb;
  --footer-bg: #1d2224;
  --footer-text: #888;
  --code-bg: #1d2224;
}

/* Reset styles */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
  display: block;
}

body {
  line-height: 1;
}

ol, ul {
  list-style: none;
}

blockquote, q {
  quotes: none;
}

blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* ===== BASE STYLES ===== */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 1.3em;
}

body {
  margin: 30px 15px 30px 15px;
  font-family: 'Inconsolata', monospace;
  background-color: var(--primary-bg);
  color: var(--text-color);
  min-width: 600px;
}

@media (max-width: 600px) {
  body {
    transform: scale(calc(100vw / 600));
    transform-origin: top left;
    width: 600px;
  }
}

/* Container */
.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Links */
a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover,
a:focus {
  filter: brightness(1.4);
  text-decoration: underline;
}

/* ===== LAYOUT COMPONENTS ===== */
/* Header */
.header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.header-top { 
  display: flex; 
  align-items: center; 
  gap: 15px;
  width: 100%;
}

.avatar-container {
  flex-shrink: 1;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
}

.avatar-container img {
  display: block;
  width: clamp(50px, 10vw, 100px);
  height: auto;
  border-radius: 15px;
}

.intro-text {
  flex: 1;
  padding-top: 4px;
  margin-left: 15px;
}

.intro-text h1,
.intro-text p {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: bold;
  line-height: 1.2;
  white-space: nowrap;
}

/* ===== SPECIALIZED COMPONENTS ===== */
/* Retro cursor */
.retro-cursor::after {
  content: '_';
  display: inline-block;
  width: 1ch;
  height: 1em;
  color: #fff;
  animation: blink 2s steps(1) infinite;
}

@keyframes blink {
  0%, 50%, 100% { opacity: 1; }
  25%, 75% { opacity: 0; }
}

/* Navigation */
.links {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 30px 0 30px 0;
}

.links ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
  list-style: none;
}

.links li:not(:last-child)::after {
  content: "::";
  margin-left: 0.3em;
  color: #aaaaaa;
}

.links a {
  color: #668888;
}

.links a:hover,
.links a:focus {
  color: #ffffff;
  text-decoration: underline;
}

/* Footer */
body > footer {
  padding: 30px 30px;
  margin: 60px -30px -30px -30px;
  background-color: var(--footer-bg);
  color: var(--footer-text);
  font-size: 0.9em;
}

body > footer a {
  color: #AA4499;
  text-decoration: none;
}

footer a:hover,
footer a:focus {
  color: #CC66bb;
  text-decoration: underline;
}

footer .footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#home {
  /* Video Wrappers */
  .video-wrapper {
    background-color: #000;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 30px;
    width: 100%;
  }

  .video-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
  }

  .video-16-9 {
    aspect-ratio: 16 / 9;
  }

  .video-16-6 {
    aspect-ratio: 16 / 6;
  }

  /* Last articles */
  #last_articles {
    margin: 30px 0;

    h2 {
      display: flex;
      align-items: center;
      font-family: 'Inconsolata';
      font-weight: bold;
      font-size: 1.7em;
      margin-bottom: 1em;

      &::before { 
        content: "#\00a0"; 
        flex-shrink: 0; 
      }

      &::after {
        content: "------------------------------------------------";
        flex-shrink: 1;
        margin-left: 0.5em;
      }
    }
  }

  .last-articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
  }

  .article-card {
    position: relative;
    display: block;
    aspect-ratio: 3 / 4;
    border-radius: 15px;
    overflow: hidden;
    background-color: #1d2224;
    text-decoration: none;
    color: #fff;
    isolation: isolate;
    transition: transform 0.2s ease, box-shadow 0.2s ease;

    &::before {
      content: "";
      position: absolute;
      inset: 0;
      background-image: var(--card-bg, none);
      background-size: cover;
      background-position: center;
      opacity: 0.9;
      transition: opacity 0.2s ease, transform 0.2s ease;
      z-index: 0;
    }

    &::after {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(180deg, rgba(0,0,0,0.12) 30%, rgba(0,0,0,0.7) 100%);
      z-index: 1;
    }

    &:hover,
    &:focus-visible {
      transform: translateY(-2px);
      box-shadow: 0 5px 18px rgba(0,0,0,0.5);
    }

    &:hover::before,
    &:focus-visible::before {
      opacity: 1;
      transform: scale(1.02);
    }
  }

  .article-card__title {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 14px;
    z-index: 2;
    font-weight: bold;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    box-sizing: border-box;
  }

  .article-card__title-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
    max-height: calc(1.25em * 2);
  }

  @media (max-width: 700px) {
    .last-articles-grid {
      grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
      gap: 12px;
    }

    .article-card {
      width: 100%;
    }
  }

  /* Code blocks */
  pre {
    border-radius: 15px !important;
    overflow: hidden;
    background-color: var(--code-bg) !important;
    margin-bottom: 30px;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5);

    code {
      display: block;
      padding: 20px;
      overflow-x: auto;
    }
  }

  /* Section headers */
  section h2, article h2 {
    display: flex;
    align-items: center;
    font-family: 'Inconsolata';
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    font-size: 1.7em;
    margin-bottom: 1em;

    &::before { 
      content: "#\00a0"; 
      flex-shrink: 0; 
    }

    &::after {
      content: "-------------------------------------------------------------------";
      flex-shrink: 1;
      margin-left: 0.5em;
    }
  }

  section h3, article h3 {
    font-size: 1.4em;
    margin-bottom: 0.5em;
  }

  section > p, article > p {
    font-size: 1.2em;
    line-height: 1.3em;
    margin-bottom: 1em;
  }

  section > ul, article > ul {
    margin-bottom: 1.8em;
  }

  /* Section spacing */
  section { 
    margin-bottom: 30px; 
  }

  section + section { 
    margin-top: 30px; 
  }

  article { 
    margin-bottom: 30px; 
  }

  article + article { 
    margin-top: 30px; 
  }

  /* Prism command-line plugin */
  .command-line-prompt > span:before {
    color: #55ccbb;
    font-weight: 700;
    border-right: none;
    margin-right: 0.6em;
  }

  .sys { 
    color: #bbcc55; 
    font-weight: 700; 
    display: block; 
  }

  .user { 
    color: #fff; 
    display: block; 
  }

  .prompt { 
    color: #55ccbb; 
    font-weight: 700; 
  }

  /* Quotes */
  .quotes {
    list-style: none;
    padding: 0;

    li {
      padding: 0;
      background-color: var(--secondary-bg);
      margin-bottom: 15px;
      padding: 15px 20px 15px 20px;
      border-radius: 15px;
      box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
      line-height: 1.3em;
    }

    blockquote {
      display: flex;
      align-items: baseline;

      footer {
        order: -1;
        margin-right: 0.5em;
        font-weight: normal;

        &::after {
          content: ":";
        }

        cite {
          font-style: normal;
          color: #55ccbb;
        }
      }

      p {
        font-style: italic;
        margin: 0;
        padding: 0;
      }
    }

    strong {
      color:#bbcc55;
    }
  }

  /* Terminal links */
  .terminal-links {
    list-style: none;
    font-size: 1.2em;
    line-height: 1.3em;
    background-color: var(--secondary-bg);
    padding: 1em;
    border-radius: 15px;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5);

    li {
      display: inline;

      &:nth-child(6n+1) a { color: #CC66BB; }
      &:nth-child(6n+2) a { color: #CC7766; }
      &:nth-child(6n+3) a { color: #BBCC66; }
      &:nth-child(6n+4) a { color: #66CC77; }
      &:nth-child(6n+5) a { color: #66BBCC; }
      &:nth-child(6n+6) a { color: #7766CC; }

      &::after {
        content: ", ";
      }

      &:last-child::after {
        content: "";
      }
    }
  }
}

/*********************************** shared media ************************************/

/* Image link overlay effect */
.video-link {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 30px;
  filter: none !important;

  video {
    width: 100%;
    height: auto;
    display: block;
  }

  &::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 0.25s ease;
  }

  &:hover::after,
  &:focus-visible::after {
    background: rgba(0,0,0,0.5);
    z-index: 1;
  }

  &::before {
    content: "open in new tab";
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 1.8rem;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 2; 
    text-shadow: 2px 2px 6px rgba(0,0,0,1);
  }

  &:hover::before,
  &:focus-visible::before {
    opacity: 1;
  }
}

/* Generic video styling */
main video {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 15px;
  margin: 0 auto;
}

/*********************************** shared media rows ************************************/

.article-media-row,
.media-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin: 1.4em 0;
  width: 100%;
  box-sizing: border-box;

  p {
    flex: 1;
    margin: 0;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  img {
    flex: 0 0 auto;
    width: auto;
    max-width: 11em;
    align-self: flex-start;
    height: auto;
    max-height: 9em;
    border-radius: 12px;
    object-fit: contain;
    background: transparent;
    padding: 0;
  }

  img.article-media-small,
  img.media-small {
    max-height: 5.5em;
    max-width: 8em;
  }
}

/*********************************** articles ***************************************/

#articles {
  /* Header fonts */
  h1, h2, h3, h4 {
    font-family: 'Inconsolata';
    font-weight: bold;
    line-height: 1.2em;
    margin-bottom: 0.8em;
  }

  article {
    margin-bottom: 40px;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }

  /* Adjusted hierarchy */
  article h1 {
    font-size: 1.8em;
  }

  article h2 {
    font-size: 1.5em;
  }

  article h3 {
    font-size: 1.3em;
  }

  article h4 {
    font-size: 1.15em;
  }

  /* Paragraphs */
  article p {
    font-size: 1.15em;
    line-height: 1.5em;
    margin-bottom: 1em;
  }

  /* Lists */
  article ul,
  article ol {
    list-style-type: decimal;
    margin: 1em 0 1.4em 1.9em;
    line-height: 1.4em;
    font-size: 1.15em;

    li {
      margin-bottom: 0.4em;
    }
  }

  /* Nested lists */
  article ul ul,
  article ol ol {
    margin: 0.4em 0 1em 1.2em;
  }

  /* Blockquotes */
  article blockquote {
    margin: 1.2em 0;
    padding: 0.8em 1.2em;
    background-color: var(--secondary-bg);
    border-radius: 12px;
    box-shadow: inset 0 0 25px rgba(0,0,0,0.4);
    border-left: 4px solid #55ccbb;
    font-style: italic;

    p {
      margin: 0;
    }
  }

  /* Code blocks */
  article pre {
    border-radius: 15px !important;
    overflow: hidden;
    background-color: var(--code-bg) !important;
    margin: 1.4em 0;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5);

    code {
      display: block;
      padding: 18px;
      overflow-x: auto;
      font-size: 0.95em;
      line-height: 1.4em;
    }
  }

  /* Inline code */
  article code:not(pre code) {
    background-color: var(--code-bg);
    padding: 0.15em 0.35em;
    border-radius: 6px;
    font-size: 0.95em;
  }

  /* Strong, em, del */
  article strong {
    font-weight: bold;
    color: #fff;
  }

  article em {
    font-style: italic;
  }

  article del {
    text-decoration: line-through;
    opacity: 0.7;
  }

  /* Images with caption */
  figure {
    margin: 1.6em 0;
    text-align: center;

    img {
      max-width: 100%;
      border-radius: 15px;
      display: block;
      margin: 0 auto;
    }

    figcaption {
      margin-top: 0.6em;
      font-size: 0.95em;
      color: #bbb;
      font-style: italic;
    }
  }

  /* Video wrappers */
  .video {
    background-color: #000;
    border-radius: 15px;
    overflow: hidden;
    width: 100%;
    margin: 1.6em 0;

    iframe,
    video {
      width: 100%;
      height: 100%;
      display: block;
      border: none;
    }
  }

  .video-16-9 { aspect-ratio: 16/9; }
  .video-16-6 { aspect-ratio: 16/6; }

  /* Horizontal rule */
  article hr {
    border: none;
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 2em 0;
  }

  /* Tables */
  article table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.6em 0;
    font-size: 1.05em;

    th,
    td {
      padding: 10px 12px;
      border: 1px solid rgba(255,255,255,0.2);
    }

    th {
      background-color: rgba(255,255,255,0.05);
      font-weight: bold;
    }
  }

  /* Links */
  article a {
    color: #55ccbb;
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }
}
