/* Offline Hello Interview fixes — Tailwind/MUI classes from scrape don't load */

/* --- Platform-safe page sizing: never clip readable content --- */
html,
body {
  width: 100%;
  max-width: 100%;
}

.layout {
  width: 100%;
  min-width: 0;
}

.main {
  width: 100%;
  min-width: 0;
  overflow-x: visible;
}

.main > *,
.main .MuiBox-root,
.main .MuiGrid-root,
.main .relative,
.main .callout > div {
  min-width: 0;
  max-width: 100%;
}

.main .mdx-p,
.main .mdx-li,
.main .callout,
.main .callout * {
  overflow-wrap: anywhere;
  word-break: normal;
}

.main a,
.main .mdx-code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* --- Simple summary (Revise native + Hello Interview) --- */
.main .simple-summary,
.simple-summary {
  margin: 0 0 20px;
  padding: 14px 16px;
  border-left: 4px solid #0f766e;
  border-radius: 0 12px 12px 0;
  background: linear-gradient(90deg, rgba(15, 118, 110, 0.1), rgba(255, 255, 255, 0.6));
  font-size: 15px;
  line-height: 1.6;
}

.main .simple-summary strong,
.simple-summary strong {
  color: #0f766e;
}

/* --- SVG / icon sizing (root cause of giant icons) --- */
.main svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  vertical-align: middle;
}

.main .MuiSvgIcon-root {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.main .callout svg,
.main .callout-tip svg,
.main .callout-warning svg,
.main .callout-info svg {
  width: 1.25rem;
  height: 1.25rem;
}

.main .MuiChip-root svg {
  width: 0.875rem;
  height: 0.875rem;
}

.main .mui-rcn95r svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* Diagram images: default to parent width, never overflow */
.main img {
  width: auto;
  max-width: 100%;
  height: auto;
}

/* 100% of PARENT only — narrow wrappers (max-w-[200px]/w-32) must constrain first */
.main [data-hi-narration-skip] img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 12px auto;
}

/* Entity / thumbnail diagrams with no Tailwind wrapper (fallback by alt text) */
.main [data-hi-narration-skip] img[alt*="Core Entities"],
.main [data-hi-narration-skip] img[alt="Entities"],
.main [data-hi-narration-skip] img[alt="Defining the Core Entities"],
.main [data-hi-narration-skip] img[alt*="Core Entity"] {
  width: auto;
  max-width: 200px;
}

/* --- Hide dead interactive UI (needs hellointerview.com login) --- */
#video-section,
button[aria-label="Copy"],
button[aria-label="zoom-in"],
.MuiButton-containedPrimary,
.MuiButton-contained.MuiButton-root,
.MuiSkeleton-root,
.animate-pulse {
  display: none !important;
}

/* --- Pattern / difficulty chips: show as read-only tags --- */
.main .MuiChip-root {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  cursor: default;
  padding: 4px 10px;
  margin: 2px 4px 2px 0;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #f3f4f6;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  vertical-align: middle;
}

.main .MuiChip-label {
  padding: 0;
}

/* --- Author / metadata row --- */
.main .mui-j7tv77 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 16px;
  font-size: 13px;
  color: #6b7280;
}

.main .mui-rcn95r {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* --- Callout variants missing from inline styles --- */
.callout-tip,
.callout-general {
  border-radius: 8px;
  padding: 14px 16px;
  margin: 16px 0;
  display: flex;
  gap: 12px;
}

.callout-tip {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
}

.callout-general {
  background: #f8fafc;
  border-left: 4px solid #64748b;
}

.callout-tip > div:first-child,
.callout-general > div:first-child {
  flex-shrink: 0;
}

/* --- Force accordions / expandables open (no JS on static site) --- */
[data-hi-expanded="false"] {
  /* attribute rewritten by fix script; fallback CSS below */
}

.MuiAccordion-root {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin: 12px 0;
  overflow: visible;
}

.main .MuiAccordionDetails-root {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.MuiAccordionSummary-root {
  padding: 12px 16px;
  background: #f9fafb;
  cursor: default;
  pointer-events: none;
  list-style: none;
}

.MuiAccordionSummary-root button {
  pointer-events: none;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  font: inherit;
  padding: 0;
  cursor: default;
}

.MuiAccordionSummary-content {
  font-weight: 600;
  font-size: 15px;
}

.MuiAccordionDetails-root,
.MuiCollapse-root,
.MuiCollapse-wrapper,
.MuiCollapse-wrapperInner {
  display: block !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  visibility: visible !important;
}

.MuiAccordion-region {
  height: auto !important;
}

.MuiAccordionSummary-expandIconWrapper {
  display: none;
}

/* Scraped DOM is [data-hi-expandable] > div[style*="max-height"] (one child). */
[data-hi-expandable] > [style*="max-height"],
[data-hi-expandable] > div[style*="max-height"],
[data-hi-expandable] [style*="max-height"] {
  max-height: none !important;
  overflow: visible !important;
}

.main .callout .mui-79elbk,
.main .callout [class*="mui-"] {
  min-width: 0;
  flex: 1 1 auto;
}

/* --- Code blocks --- */
.main pre {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

.main .mui-1e0b4d {
  display: none;
}

.main table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Tables / lists in accordions --- */
.main .mdx-h6 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 16px 0 8px;
}

.main .mdx-ol,
.main .mdx-ul {
  padding-left: 24px;
  margin-bottom: 14px;
}

/* --- Sidebar back link --- */
.sidebar-back {
  display: block;
  padding: 10px 16px 12px;
  font: 600 13px/1.3 ui-sans-serif, system-ui, sans-serif;
  color: #0f766e;
  text-decoration: none;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 8px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.06), transparent);
}

.sidebar-back:hover {
  color: #0d9488;
  text-decoration: none;
}

/* --- Local link indicator (optional subtle) --- */
.main a.mdx-a[href^="learn__"],
.main a.mdx-a[href^="./learn__"] {
  color: #1d4ed8;
}

/* --- Tailwind / MUI layout shims (scrape never ships Tailwind/Emotion CSS) --- */

/* Flexbox core — page chrome, chips, accordion stacks */
.main .flex,
.chrome .flex,
.sidebar .flex {
  display: flex;
}

.main .inline-flex {
  display: inline-flex;
}

.main .flex-col,
.chrome .flex-col {
  flex-direction: column;
}

.main .flex-row {
  flex-direction: row;
}

.main .flex-wrap {
  flex-wrap: wrap;
}

.main .items-center,
.chrome .items-center {
  align-items: center;
}

.main .items-start {
  align-items: flex-start;
}

.main .justify-between,
.chrome .justify-between {
  justify-content: space-between;
}

.main .justify-center {
  justify-content: center;
}

.main .gap-2 { gap: 0.5rem; }
.main .gap-3 { gap: 0.75rem; }
.main .gap-4 { gap: 1rem; }
.chrome .gap-2 { gap: 0.5rem; }

.main .relative { position: relative; }
.main .absolute { position: absolute; }
.main .top-0 { top: 0; }
.main .right-0 { right: 0; }

.main .mx-auto,
.main [class*="mx-auto"] {
  margin-left: auto;
  margin-right: auto;
}

.main .my-4 { margin-top: 1rem; margin-bottom: 1rem; }
.main .my-6 { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.main .mt-2 { margin-top: 0.5rem; }
.main .mt-6 { margin-top: 1.5rem; }
.main .mb-3 { margin-bottom: 0.75rem; }
.main .mb-4 { margin-bottom: 1rem; }
.main .py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

/* Width utilities — class + attribute selectors (brackets need both) */
.main .w-3 { width: 0.75rem; }
.main .w-3\.5 { width: 0.875rem; }
.main .w-4 { width: 1rem; }
.main .w-5 { width: 1.25rem; }
.main .w-6 { width: 1.5rem; }
.main .w-32,
.main [class*="w-32"] { width: 8rem; max-width: 8rem; }
.main .w-64,
.main [class*="w-64"] { width: 16rem; max-width: 16rem; }
.main .w-\[250px\],
.main [class*="w-[250px]"] { width: 250px; max-width: 100%; }
.main .w-full { width: 100%; }

.main .h-3 { height: 0.75rem; }
.main .h-3\.5 { height: 0.875rem; }
.main .h-4 { height: 1rem; }
.main .h-5 { height: 1.25rem; }
.main .h-6 { height: 1.5rem; }
.main .h-auto { height: auto; }

.main .max-w-sm,
.main [class*="max-w-sm"] { max-width: 24rem; }
.main .max-w-md { max-width: 28rem; }
.main .max-w-72,
.main [class*="max-w-72"] { max-width: 18rem; }
.main .max-w-5xl { max-width: 64rem; }
.main .max-w-7xl { max-width: 80rem; }
.main .max-w-full { max-width: 100%; }
.main .max-w-\[200px\],
.main [class*="max-w-[200px]"] { max-width: 200px; }
.main .max-w-\[300px\],
.main [class*="max-w-[300px]"] { max-width: 300px; }
.main .max-w-\[400px\],
.main [class*="max-w-[400px]"] { max-width: 400px; }

@media (min-width: 768px) {
  .main .md\:flex-row,
  .chrome .md\:flex-row { flex-direction: row; }
  .main .md\:items-start,
  .chrome .md\:items-start { align-items: flex-start; }
  .main .md\:justify-between,
  .chrome .md\:justify-between { justify-content: space-between; }
  .main .md\:gap-4,
  .chrome .md\:gap-4 { gap: 1rem; }
}

/* MUI Grid figure wrappers around diagrams */
.main .MuiGrid-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.main .MuiGrid-direction-xs-column {
  flex-direction: column;
}

.main .MuiGrid-direction-xs-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

.main .MuiTypography-caption {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
  text-align: center;
}

.main .MuiPaper-root.MuiAccordion-root {
  box-shadow: none;
  border: 1px solid #e5e7eb;
}

.main .mx-auto.w-32,
.main .mx-auto.w-64,
.main [class*="max-w-[200px]"],
.main [class*="max-w-[300px]"] {
  display: block;
}

@media (max-width: 768px) {
  .main {
    width: 100%;
    max-width: 100%;
    padding: 16px;
  }

  .main .callout,
  .main .callout-tip,
  .main .callout-general {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    gap: 10px;
    align-items: flex-start;
  }

  .main pre {
    padding: 14px;
    font-size: 0.8em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .main pre code {
    white-space: inherit;
    overflow-wrap: inherit;
    word-break: inherit;
  }

  .main img,
  .main svg {
    max-width: 100%;
  }
}
