/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@100;200;300;400;500;600;700;800;900&family=Noto+Sans+Arabic:wght@100;200;300;400;500;600;700;800;900&display=swap');

/* =========================
   Theme Variables
   ========================= */
   :root {
    --bg: #d8f2df;
    --fg: #F0230A;
    --muted: #F0230A;
    --line: #232633;
    --chip: #171923;
    --card: #141724;
    --accent: #F0230A;
    --badge: #0ea5e9;
  }
  
  /* =========================
     Base Styles
     ========================= */
  * {
    box-sizing: border-box;
  }
  
  html,
  body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: "Lexend", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    /* Support for RTL languages like Arabic */
    direction: auto;
    unicode-bidi: plaintext;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  html::-webkit-scrollbar,
  body::-webkit-scrollbar {
    display: none;
  }
  
  a {
    color: inherit;
  }

  h1 { font-size: 32px; font-weight: 500;margin: 0; }
  h2 { font-size: 22px; font-weight: 500; margin: 0; }
  h3 { font-size: 18px; font-weight: 300; margin: 0; }
  p  { font-size: 22px; margin: 0; }
  
  .small { font-size: 14px; }

  /* paragraph style already set above */
  
  /* =========================
     Header
     ========================= */
  .site-header {
    max-width: none;
    width: 94.5%;
    margin-left: 0;
    display: grid;
    grid-template-columns: 11.11% 11.11% 11.11% 33.33% 33.33%;
    column-gap: 16px;
    align-items: center;
    background: var(--bg);
    padding-left: 5.5%;
    /* mirror .grid right inset */
    padding-top: 3%;
    
    }

  .site-title {
    font-size: 42px;
    margin: 0;
  }
  
  
  .brand {
    display: flex;
    flex-direction: column;
    justify-content: center; /* vertical alignment within header */
    align-items: flex-start; /* keep left-aligned */
    gap: 6px; /* consistent spacing between title and subtitle */
    align-self: stretch; /* fill header row height so centering takes effect */
    grid-column: 1 / span 4; /* Span from column 1 to 4 (leaving column 5 for actions) */
  }
  
  .site-subtitle {
    max-width: 85%;
    margin: revert;
   
  }
  
  /* Portrait mode - adjust subtitle width */
  @media (orientation: portrait) {
    .site-subtitle {
      max-width: 96%;
    }
  }
  
  /* =========================
     Actions
     ========================= */
  .actions {
    display: flex;
    flex-direction: column;
    gap: 24px;
    grid-column: 5; /* Align with the author column */
    /* justify-self: start; */
    align-self: stretch; /* match header row height */
    justify-content: center; /* center buttons vertically */
    padding-left: 0; /* Ensure no left padding */
    margin-left: 0; /* Ensure no left margin */
    padding-right: 30.9%;
  }

  .actions .btn {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    text-decoration: none;
    color: var(--fg);
  }
  
  .actions .btn:hover { opacity: .85; }
  
  /* Hamburger - hidden on desktop, shown on mobile */
  .hamburger {
    display: none;
  }
  
  /* Mobile hamburger menu */
  @media (max-width: 768px) {
    /* Mobile font sizes - 2/3 of desktop */
    h1 { font-size: 21px; } /* 32px * 2/3 = 21.33px */
    h2 { font-size: 15px; } /* 22px * 2/3 = 14.67px */
    h3 { font-size: 12px; font-weight: 500; } /* 18px * 2/3 = 12px */
    p  { font-size: 15px; } /* 22px * 2/3 = 14.67px */
    .small { font-size: 12px; } /* 14px * 2/3 = 9.33px */
    
    .hamburger {
      display: flex;
    }
    
    
      .site-header {
          width: 85%;
          margin-left: 7.5%;
          padding: 0;
          position: relative;
    
          /* vertical centering only */
          min-height: 100vh;        /* fill viewport */
          display: flex;
          flex-direction: column;
          justify-content: center;  /* center vertically */
          align-items: flex-start;  /* keep left aligned */
      }
    
      .brand {
          text-align: left;   /* make sure text stays left */
          align-items: flex-start;
          gap: 6px;
      }
  
    
    .site-title {
      position: fixed;
      top: 20px;
      left: 20px;
      font-size: 16px;    
      z-index: 1000;
      font-weight: 700;
      background: var(--bg);
      padding: 0;
      margin: 0;
      color: var(--fg);
      opacity: 0;
      transition: opacity 0.3s ease;
      pointer-events: none;
    }
    
    /* Show site-title after scrolling down one page length */
    .site-title.show-on-scroll {
      opacity: 1;
      pointer-events: auto;
    }
    
    .site-subtitle {
      max-width: 100%;
      font-size: 16px; /* 15px + 2px */
    }
    
    .title-emphasis {
      font-weight: 800;
    }
    

    
    .actions {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: var(--bg);
      /* border-bottom: 2px solid var(--fg); */
      padding: 16px;
      z-index: 1001;
      transform: translateY(-100%);
      transition: transform 0.3s ease;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      gap: 32px;
      grid-column: unset;
      justify-self: unset;
    }
    
    .actions.is-open {
      transform: translateY(0);
    }
    
    .hamburger {
      position: fixed;
      top: 16px;
      right: 16px;
      width: 30px;
      height: 30px;
      background: transparent;
      border: none;
      cursor: pointer;
      z-index: 1002;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      padding: 0;
    }
    
    .hamburger span {
      display: block;
      width: 100%;
      height: 3px;
      background: var(--fg);
      transition: all 0.3s ease;
    }
    
    .hamburger.is-open span:nth-child(1) {
      transform: rotate(45deg) translate(8px, 8px);
    }
    
    .hamburger.is-open span:nth-child(2) {
      opacity: 0;
    }
    
    .hamburger.is-open span:nth-child(3) {
      transform: rotate(-45deg) translate(6px, -6px);
    }
  }
  
  /* =========================
     Triangle Icon
     ========================= */
  .tri {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: middle;
  }
  
  .tri img {
    display: block;
    /* width: 100%; */
    height: 100%;
  }
  
  .tri--btn {
    width: 96px;
    height: 96px;
  }
  
  .tri--flip {
    transform: rotate(180deg);
  }
  
  /* =========================
     Tabs
     ========================= */
  .tabs {
    position: fixed;
    top: 50vh; /* stays docked below the fixed header */
    left: 2.5%;
    width: 40px;
    height: 45vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1.5px solid var(--fg);
    border-radius: 0;
    background: transparent;
    align-items: stretch;
    z-index: 10;
    transform: rotate(180deg);
    transform-origin: center;
    overflow: hidden;
  }
  
  /* When footer visible, let tabs fade out and stop intercepting clicks */
  body.tabs-autohide.footer-visible .tabs {
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }
  
  .tab {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 0 8px;
    text-align: center;
    border: 0;
    border-bottom: 1.5px solid var(--fg);
    border-radius: 0;
    background: transparent;
    text-decoration: none;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: var(--fg);
    transition: all 0.2s ease;
    cursor: pointer;
  }
  
  .tab:last-child {
    border-bottom: none;
  }
  
  .tab.is-active {
    background: var(--fg);
    color: #fff;
  }
  
  .tab:hover:not(.is-active) {
    background: rgba(230, 59, 31, 0.08);
  }

  .tabs {
    /* existing properties */
    transition: opacity 200ms ease;
  }
  
  /* Mobile tabs */
  @media (max-width: 768px) {
    .tabs {
      position: sticky;
      top: 62px;
      left: 0;
      width: 100%;
      height: auto;
      transform: none;
      transform-origin: center;
      border: unset;
      border-top: 2px solid var(--fg);
      border-bottom: 2px solid var(--fg);
      background: var(--bg);
      z-index: 15;
      padding: 0;
      margin: 0;
      flex-direction: row;
      box-shadow: 0 -50px 0 50px var(--bg);
    }
    
    .tab {
      writing-mode: horizontal-tb;
      text-orientation: mixed;
      padding: 8px 16px;
      border: none;
      border-right: 2px solid var(--fg);
      flex: 1;
      text-align: center;
      margin: 0;
      height: 100%;  
    }
    
    .tab:last-child {
      border-right: none;
    }
  }
  
  /* =========================
     Grid Layout
     ========================= */
     .grid {
      --col-gap: 16px;
    
      position: fixed;
      top: 13.333vh;
      left: 0;
      right: 0;
      bottom: 16px;
    
      margin: 0;
      display: grid;
      grid-template-columns: 11.11% 11.11% 11.11% 33.33% 33.33%;
      column-gap: var(--col-gap);
      row-gap: 32px;
      align-items: start;
      scrollbar-width: none;
      -ms-overflow-style: none;
    
      padding-left: 5.5%;
      
      max-width: 94.5%;
    }
    
  
  /* Mobile grid layout */
  @media (max-width: 768px) {
    .grid {
      position: static;
      top: auto;
      right: auto;
      bottom: auto;
      margin: 0;
      padding: 20px;
      grid-template-columns: 15% 60% 15%;
      column-gap: 16px;
      row-gap: 16px;
      align-items: start;
      max-width:unset;
    }
    
    .grid .grid-marker {
      height: 35px !important;
      width: 35px !important;
      transition: transform 250ms ease, opacity 250ms ease;
    }

    .grid .marker-author {
      grid-column: 3 !important;
    }
    
    .grid .marker-year {
      grid-column: 1 !important;
    }
    
    .year {
      font-size: 11px !important;
      grid-column: 1 !important;
      line-height: 1.5 !important;
    }
    
    .title {
      grid-column: 2 !important;
      display: block !important;
      width: auto !important;
      justify-self: start !important;
      transform: translateY(-1px);
    }
    
    .title::after {
      content: "";
    } 
    
    /* Hide desktop author version on mobile */
    .desktop-author {
      display: none !important;
    }
    
    /* Show mobile author version on mobile */
    .mobile-author {
      grid-column: 3 !important;
      display: block !important;
      white-space: normal !important;
      font-size: 11px !important;
     
    }

    .card .author {
      padding-right: unset !important;
    }
    
    .open {
      display: none !important;
    }
    
    /* Remove transform translate on mobile for favicon markers */
    .grid .marker-year {
      transform: translateX(1px) rotate(0deg) !important;
      margin-top: 10px;
      margin-bottom: 12px;
    }
    .grid .marker-year.is-desc {
      transform: translateX(-16px) rotate(-180deg) !important;
      margin-top: 10px;
      margin-bottom: 12px;
    }
    .grid .marker-author {
      transform: translateX(1px) rotate(0deg) !important;
      margin-top: 10px;
      margin-bottom: 12px;
    }
    .grid .marker-author.is-desc {
      transform: translateX(-16px) rotate(-180deg) !important;
      margin-top: 10px;
      margin-bottom: 12px;
    }
  }
  
  .grid::-webkit-scrollbar {
    display: none;
  }
  
  .grid .grid-markers {
    display: contents; /* let markers align to grid columns */
  }
  
  .grid .grid-marker {
    width: 44px;
    height: 44px;
    transform-origin: center;
    cursor: pointer;
    transition: transform 250ms ease, opacity 250ms ease;
    /* justify-self: center;
    align-self: start; */
  }
  
  .grid .grid-marker.is-inactive {
    opacity: 0.3;
  }
  
  .grid .grid-marker img {
    
    height: 100%;
    display: block;
  }
  
  .grid .marker-year {
    grid-column: 2;
    transform: translateX( 2px) rotate(0deg);
    /* justify-self: center;
    align-self: start; */
  }
  .grid .marker-year.is-desc { transform: translateX(-20px) rotate(-180deg); }
  
  .grid .marker-author {
    grid-column: 5;
   transform: translateX( 1px) rotate(0deg);    
    /* justify-self: center;
    align-self: start; */
  }
  .grid .marker-author.is-desc { transform:translateX(-21px) rotate(-180deg); }
  
  /* =========================
     Cards
     ========================= */
  .card {
    column-gap: var(--col-gap);
    background: transparent; 
    border: none;
    border-radius: 0;
    padding: 6px 0;
    display: contents; /* flatten into parent .grid */
  }
  
  @media (max-width: 1100px) {
    .card {
    grid-template-columns: 80px 120px 1fr 320px;
    }
  }

/* Children of .card are now direct grid items of .grid via display: contents */
  
  .card .title {
    min-width: 0;
  }
  
  .card .author {
    text-align: left;
    padding-right: 30.9%;
  }
  
  /* =========================
     Meta & Text
     ========================= */
  .meta .year,
  .year {
    min-width: 64px;
    font-weight: 500;
    line-height: 1;
    text-align: right;
  }
  
  .year {
    grid-column: 2;
    /* place-self: start center; */
    text-align: left; 
    align-self: start;
    margin-top:0; 
  }
  
  .open {
    grid-column: 3;
    font-weight: 400; 
    /* text-align: center;
    align-self: start; */
  }
  
  .title {
    grid-column: 4;
    text-align: left;
    /* justify-self: center;
    width: 85%; */
    align-self: start;
    padding-right: 10%;
  }
  
  .title a:hover {
    border-color: var(--accent);
  }
  
  .author,
  .type {
    color: var(--fg);
    font-weight: 500;
  }
  
  .author {
    grid-column: 5;
    text-align: left;
    align-self: start;
    padding-right: 10%;
  }
  
  /* Desktop: show desktop version, hide mobile version */
  .desktop-author {
    display: block;
  }
  
  .mobile-author {
    display: none;
  }
  
  /* Right-justify Arabic text */
  .author:lang(ar),
  .title:lang(ar),
  .author[dir="rtl"],
  .title[dir="rtl"] {
    text-align: right;
  }
  
  /* Auto-detect Arabic characters and apply RTL */
  .author:not([dir]),
  .title:not([dir]) {
    unicode-bidi: plaintext;
  }

  /* Use Noto Sans for Arabic text */
  .author:lang(ar),
  .title:lang(ar),
  .author[dir="rtl"],
  .title[dir="rtl"],
  [lang="ar"],
  [dir="rtl"] {
    font-family: "Noto Sans", "Noto Sans Arabic", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  }
  
  .type {
    display: none;
  }
  
  /* =========================
     Footer
     ========================= */
  .site-footer {
    margin: 35vh 0; /* 15vh above and below */
    text-align: center;
  }
  
  .site-footer .copyright {
    display: inline-block;
    max-width: 30%;
  }

  @media (max-width: 768px) {
    .site-footer .copyright {
      max-width: 70%;
    }

    .site-footer {
      margin: 25vh 0; /* 15vh above and below */
      text-align: center;
    }
  }

  /* Hide all tab grids by default */
.grid[data-tab] {
  display: none;
}

/* Show only the active tab's grid */
.grid[data-tab].is-active {
  display: grid;
}
  