@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap');

:root {
  --base-clr: var(--black);
  --line-clr: var(--base-850);
  --hover-clr: var(--base-900);
  --text-clr: var(--base-200);
  --accent-clr: var(--cyan-600);
  --secondary-text-clr: var(--base-500);

  /* === flexoki color scheme === */
  --black: #100F0F;
  --base-950: #1C1B1A;
  --base-900: #282726;
  --base-850: #343331;
  --base-800: #403E3C;
  --base-700: #575653;
  --base-600: #6F6E69;
  --base-500: #878580;
  --base-300: #B7B5AC;
  --base-200: #CECDC3;
  --base-150: #DAD8CE;
  --base-100: #E6E4D9;
  --base-50: #F2F0E5;
  --paper: #FFFCF0;


  --orange-600: #BC5215;
  --yellow-600: #AD8301;
  --green-600: #66800B;
  --cyan-600: #24837B;
  --blue-600: #205EA6;
  --purple-600: #5E409D;
  --magenta-600: #A02F6F;

}

.darkmode {
  --base-clr: var(--base-50);
  --line-clr: var(--base-300);
  --hover-clr: var(--base-100);
  --text-clr: var(--base-600);
  --secondary-text-clr: var(--base-700);
  --accent-clr: var(--cyan-600);
}

* {
  margin: 0;
  padding: 0;
}

html {
  font-family: "IBM Plex Mono", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.5rem;
  font-optical-sizing: auto;
  font-style: normal;
  font-size: 13px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--base-clr);
  color: var(--text-clr);
  display: grid;
  grid-template-columns: auto 1fr;

}

#sidebar {
  box-sizing: border-box;
  height: 100vh;
  width: 250px;
  padding: 5px 1em;
  background-color: var(--base-clr);

  position: sticky;
  top: 0;
  align-self: start;
  overflow: hidden;
  text-wrap: nowrap;

  display: flex;
  flex-direction: column;
}

#sidebar.close {
  padding: 5px;
  width: 58px;
}

#sidebar ul {
  list-style: none;
}

/* === Sidebar header (logo + theme toggle) === */
#sidebar>ul>li.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1em;
  margin-top: 1em;
}

.sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 0.5em;
  flex-wrap: wrap;

}

/* Independent logo link styling — unaffected by sidebar <a> defaults */
#sidebar .logo {
  all: unset;
  /* remove inherited sidebar link styles */
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-clr);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  line-height: 1.6rem;

  max-width: 100%;
  white-space: normal;
  word-break: break-word;
}

#sidebar .logo:hover {
  background: none !important;
  color: var(--text-clr) !important;
}


#sidebar ul li.active a {
  color: var(--accent-clr);
}

/* Make the top-level sidebar header a column flex container so its
   <li> children layout correctly. The scrolling list is a separate
   sibling `.sidebar-scroll` which receives `flex: 1` to take remaining
   height and enable overflow. */
#sidebar>ul:first-child {
  display: flex;
  flex-direction: column;
}

#sidebar a,
#sidebar .logo {
  border-radius: .5em;
  padding: 0.62em;
  /* original - 0.62em */
  text-decoration: none;
  color: var(--text-clr);
  display: flex;
  align-items: center;
  gap: 1em;
}

.sidebar-scroll {
  flex: 1;
  /* take remaining height */
  overflow-y: auto;
  padding-right: 4px;
  /* prevents scrollbar overlap */
}

.sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background-color: var(--line-clr);
  border-radius: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent-clr);
}

/* Make all sidebar link text bold except the logo */
#sidebar a:not(.logo) {
  font-weight: 500;
  font-size: 0.98rem;
  /* original - 0.98rem */
}

#sidebar svg {
  flex-shrink: 0;
  fill: var(--text-clr);
}

#sidebar a span {
  flex-grow: 1;
}

#sidebar a span.emoji {
  flex-grow: 0;
  font-size: 18px
}

#sidebar a:hover,
.card:hover {
  background-color: var(--hover-clr);
}

.sidebar-link .label {
  display: inline-block;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#password-input {
  padding: 0.4em 0.8em;
  border: 1px solid var(--line-clr);
  border-radius: 0.3em;
  background-color: var(--base-clr);
  color: var(--text-clr);
}

.unlock-button {
  margin-left: 0rem;
  padding: 0.45em 0.85em;
  border: none;
  background-color: var(--accent-clr);
  color: var(--base-clr);
  font-weight: 600;
  border-radius: 0.2em;
  cursor: pointer;
}

#lock-button {
  margin-left: 0rem;
  padding: 0.45em 0.85em;
  border: 1px solid var(--accent-clr);
  background-color: var(--base-clr);
  color: var(--accent-clr);
  font-weight: 600;
  border-radius: 0.2em;
  cursor: pointer;
}


#theme-switch {
  margin-left: auto;
  padding: 0.5em;
  height: 40px;
  width: 40px;
  border-radius: 50%;
  border: 0.12rem solid var(--line-clr);
  background-color: var(--base-clr);
  box-sizing: border-box;
  background-clip: padding-box;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

#theme-switch:hover {
  background-color: var(--hover-clr);
}

#theme-switch svg {
  fill: var(--text-clr);
  display: block;
  width: 24px;
  height: 24px;
}

#theme-switch svg:last-child {
  display: none;
}

.darkmode #theme-switch svg:first-child {
  display: none;
}

.darkmode #theme-switch svg:last-child {
  display: block;
}

main {
  padding: min(40px, 7%);

}

main p {
  color: var(--secondary-text-clr);
  margin-top: 5px;
  margin-bottom: 15px;
}

#content {
  max-width: 1900px;
  margin: 0 auto;
}

.container {
  border: 1px solid var(--line-clr);
  border-radius: 1em;
  margin-bottom: 20px;
  padding: min(3em, 15%);

  h2,
  p {
    margin-top: 1em
  }
}

.card {
  border: 1px solid var(--line-clr);
  border-radius: 8px;
  padding-left: min(1.4em, 10%);
  padding-right: min(0.75em, 8%);
  padding-top: min(0.8em, 8%);
  padding-bottom: min(0.8em, 8%);

  h3,
  p {
    margin-top: 1em
  }

  h3 {
    font-size: 1.2rem;
  }

  p {
    font-family: Calibri, 'Trebuchet MS', sans-serif;
    font-size: 16px;
  }

  color: inherit;
  text-decoration: none;
}

.card-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-content .favicon img {
  width: 24px;
  height: 24px;
  margin-right: 0.6rem;
  vertical-align: middle;
}

/* Group bottom elements */
.card-content .bottom {
  margin-top: auto;
  /* push this group to bottom */
}

/* Bottom group elements, small spacing before tags */
.card-content .bottom .link {
  margin-bottom: 0.5rem;
}

.card-content h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  /* limit to 2 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-content p {
  margin-top: 1rem;
  margin-bottom: 0.4rem;
}

.card:visited {
  color: inherit;
  text-decoration: none;
}

.card p.link {
  margin-top: 1em;
  text-decoration: none;
  font-size: 0.9rem;
}

.tag {
  background-color: var(--secondary-text-clr);
  color: var(--base-clr);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-block;
  white-space: nowrap;
  line-height: 1;
}

.title-container {
  border-radius: 0.5em;
  margin-bottom: 6px;
  padding-bottom: min(1.5em, 15%);
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 15px;
  justify-content: left;
  margin-bottom: 5rem;
}

/* === Hero Section === */
.hero {
  text-align: center;
  padding: 6rem 1rem 2rem 1rem;
  background: var(--base-clr);
  margin-bottom: 8rem;
}

.hero-content {
  max-width: 700px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  color: var(--text-clr);
  margin-bottom: 0.5rem;
}

.hero .subtitle {
  color: var(--secondary-text-clr);
  font-size: 1rem;
  margin-top: 1.2rem;
  margin-bottom: 2.5rem;
}

/* Search bar container */
.search-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--hover-clr);
  border: 1px solid var(--line-clr);
  border-radius: 9999px;
  padding: 0.4rem 0.8rem;
  max-width: 450px;
  margin: 0 auto;
  transition: border-color 0.2s ease;
}

.search-bar:focus-within {
  border-color: var(--accent-clr);
}

.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-clr);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem;
}

.search-bar input::placeholder {
  color: var(--secondary-text-clr);
}

.search-bar button {
  background: none;
  border: none;
  color: var(--secondary-text-clr);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.3rem;
}

.search-bar button:hover {
  color: var(--accent-clr);
}

/* --- Credits button --- */
.sidebar-footer-btn {
  width: 100%;
  padding: 0.85em;
  border: none;
  background: none;
  color: var(--text-clr);
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 0.5em;
  margin-top: auto;
}


/* --- Overlay styling --- */
.overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.darkmode .overlay {
  background-color: rgba(255, 255, 255, 0.7);
}

.overlay.show {
  display: flex;
}

.overlay-content {
  background-color: var(--base-clr);
  color: var(--text-clr);
  padding: 2em;
  border-radius: 1em;
  max-width: 680px;
  width: 90%;
  position: relative;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.overlay-content a {
  color: var(--accent-clr);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.overlay-content a:hover {
  color: var(--text-clr);
}

.close-overlay {
  position: absolute;
  top: 0.5em;
  right: 0.75em;
  background: none;
  border: none;
  font-size: 1.5em;
  color: var(--text-clr);
  cursor: pointer;
}

.close-overlay:hover {
  color: var(--accent-clr);
}

@media(max-width: 800px) {
  body {
    grid-template-columns: 1fr;
  }

  main {
    padding: 2em 1em 60px 1em;
  }

  .container {
    border: none;
    padding: 0;
  }

  .grid-container {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 10px;
  }

  .card {
    padding: 1em;
  }

  .title-container {
    padding: 1.5em;
  }

  #sidebar {
    display: block;
    height: 60px;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--line-clr);
    padding: 0;
    position: fixed;
    top: unset;
    bottom: 0;
    z-index: 999;

    >ul {
      padding: 0;
      display: grid;
      grid-auto-columns: 60px;
      grid-auto-flow: column;
      justify-content: center;

      max-height: calc(100vh - 60px);
      overflow-x: auto;
      overflow-y: auto;

      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
    }

    >ul::-webkit-scrollbar {
      height: 0;
      width: 0;
    }

    ul li {
      height: 100%;
    }

    ul a {
      width: 60px;
      height: 60px;
      padding: 0;
      border-radius: 0;
      justify-content: center;
    }

    ul li span,
    ul li:first-child {
      display: none;
    }

    ul li span.emoji {
      display: inline;
      font-size: 1.5rem;
    }
  }

  .sidebar-footer-btn {
    display: none;
  }

  .hero {
    padding: 2rem 1rem;
    margin-bottom: 3rem;
  }

  .search-bar {
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .grid-container {
    grid-template-columns: 1fr;
    /* always single column */
  }

  .card {
    padding: 0.9em;
  }

  h3 {
    font-size: 1rem;
  }

  .card p.link {
    font-size: 0.8rem;
  }

  .tag {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
  }

  .title-container {
    padding: 1.2em;
    margin-bottom: 1.4em;
  }
}