/* =======================================================================
   STAT 350 — custom style sheet
   Works with Read-the-Docs / sphinx_rtd_theme; degrades gracefully on
   other themes.
   ======================================================================= */

/* -----------------------------------------------------------------------
   1. Global typography & smooth scrolling
   -------------------------------------------------------------------- */
html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans",
                 "Source Sans Pro", sans-serif;
    line-height: 1.55;
    scroll-behavior: smooth;              /* pleasant jump-to-anchor */

    /* ---------- CONTRAST FIX: darker body text (15 : 1) -------------- */
    color: #202020;
}

/* Headings — crisper letter-spacing and weight */
.rst-content h1,
.rst-content h2,
.rst-content h3,
.rst-content h4 {
    font-weight: 700;
    letter-spacing: -0.015em;
    /* ---------- CONTRAST FIX: text darker than body ------------------ */
    color: #121212;
}

/* Offset headings so fixed RTD nav bar doesn’t hide them */
:target::before {
    content: "";
    display: block;
    height: 80px;
    margin-top: -80px;
}

/* -----------------------------------------------------------------------
   2. Links — subtle animated underline
   -------------------------------------------------------------------- */
/* ---------- CONTRAST FIX: blue passes 4.5 : 1 ------------------------- */
a,
a:visited {
    color: #005fa3;      /* was #2980b9 (fail 3.9 : 1) */
    text-decoration: none;
    box-shadow: inset 0 -2px 0 rgba(0, 95, 163, 0.35);
    transition: box-shadow 0.2s ease;
}
a:hover,
a:focus-visible {
    text-decoration: underline; /* extra cue beyond colour */
    box-shadow: inset 0 -14px 0 rgba(0, 95, 163, 0.25);
}

/* Dark-mode link colour (≥ 4.5 : 1 on #282c34) */
@media (prefers-color-scheme: dark) {
    a,
    a:visited {
        color: #70b8ff;  /* 4.8 : 1 */
        box-shadow: inset 0 -2px 0 rgba(112, 184, 255, .45);
    }
    a:hover,
    a:focus-visible {
        box-shadow: inset 0 -14px 0 rgba(112, 184, 255, .35);
    }
}

/* -----------------------------------------------------------------------
   3. Admonitions / topic boxes — “card” look
   -------------------------------------------------------------------- */
div.admonition,
div.topic {
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
}
div.admonition > p.admonition-title {
    font-weight: 600;
    margin-bottom: .5rem;
}

/* Dark-mode adjustment */
@media (prefers-color-scheme: dark) {
    div.admonition,
    div.topic {
        background: #222;
        box-shadow: 0 2px 6px rgba(0, 0, 0, .6);
    }
}

/* -----------------------------------------------------------------------
   4. Content width — wider reading pane
   -------------------------------------------------------------------- */
.rst-content {
    max-width: none !important;   /* remove RTD’s 800 px cap */
    width: 100% !important;
}

/* 4 bis — lift hard cap on outer column (RTD default = 800 px) */
.wy-nav-content {
    max-width: none !important;
    width: 100% !important;
}
@media (min-width: 1400px) {
    .wy-nav-content {
        max-width: 1600px !important;
        margin-left: auto;
        margin-right: auto;
    }
}

/* -----------------------------------------------------------------------
   5. Tables — zebra stripes + mobile scroll
   -------------------------------------------------------------------- */
table.docutils {
    border-collapse: collapse;
    width: 100%;
    display: table;             /* mobile scroll disabled. Table will wrap text instead */
    /* overflow-x: auto */;
    white-space: normal;
    /* scroll-snap-type: x mandatory */;
}
table.docutils th,
table.docutils td {
    padding: .6rem .9rem;
}
/* ---------- CONTRAST FIX: darker stripe  (bg 5 % vs 3 %) -------------- */
table.docutils tbody tr:nth-child(odd) {
    background: rgba(0, 0, 0, 0.05);
}
/* snap alignment for smooth flick scroll */
table.docutils tr,
table.docutils th,
table.docutils td {
    scroll-snap-align: start;
}
/* dark-mode stripe */
@media (prefers-color-scheme: dark) {
    table.docutils tbody tr:nth-child(odd) {
        background: rgba(255, 255, 255, 0.07);
    }
}

/* override table no-wrap; added by Halin*/
.wy-table-responsive table td, .wy-table-responsive table th {
    white-space: normal;
}

/* -----------------------------------------------------------------------
   6. Code blocks — improved readability with syntax highlighting
   -------------------------------------------------------------------- */
/* Inline code ---------------------------------------------------------------- */
.rst-content code {
    /* ---------- CONTRAST FIX: lighter bg, darker fg (5.1 : 1) -------- */
    background: #fdfdfd;
    color: #b31d28;          /* was #c7254e */
}

/* Block code ----------------------------------------------------------- */
div.highlight pre {
    /* ---------- CONTRAST FIX ----------------------------------------- */
    background: #f4f4f4;          /* was #f8f9fa */
    border-left: 4px solid #005fa3; /* mirrors new link blue */
    border-radius: 3px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
    line-height: 1.5;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    color: #202020;
}

/* Light-theme syntax colours (unchanged except base text above) */
.highlight .k, .highlight .kd, .highlight .kn { color: #8959a8; font-weight: bold; }
.highlight .n, .highlight .nb { color: #333333; }
.highlight .nf { color: #4271ae; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #718c00; }
.highlight .c, .highlight .c1 { color: #8e908c; font-style: italic; }
.highlight .m, .highlight .mi, .highlight .mf { color: #f5871f; }
.highlight .o, .highlight .ow { color: #3e999f; }

/* Dark-mode block code */
@media (prefers-color-scheme: dark) {
    div.highlight pre {
        background: #282c34;
        border-left: 4px solid #61afef;
        color: #abb2bf;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }
    /* One Dark palette */
    .highlight .k, .highlight .kd, .highlight .kn { color: #c678dd; }
    .highlight .n, .highlight .nb { color: #e5c07b; }
    .highlight .nf { color: #61afef; }
    .highlight .s, .highlight .s1, .highlight .s2 { color: #98c379; }
    .highlight .c, .highlight .c1 { color: #7f848e; }
    .highlight .m, .highlight .mi, .highlight .mf { color: #d19a66; }
    .highlight .o, .highlight .ow { color: #56b6c2; }
}

/* -----------------------------------------------------------------------
   7. Navigation / sidebar (contrast-safe)
   -------------------------------------------------------------------- */
.wy-nav-side,
.wy-side-scroll {
    background: #343131;      /* RTD default */
}

.wy-menu-vertical a,
.wy-menu-vertical a:visited {
    color: #e6e6e6;           /* 12 : 1 on #343131 */
}
.wy-menu-vertical a:hover,
.wy-menu-vertical a:focus,
.wy-menu-vertical li.current > a {
    color: #70b8ff;           /* 4.8 : 1 */
}

.wy-menu-vertical .caption {
    color: #f3f3f3;
    font-weight: 600;
}

.wy-nav-side {
    font-size: 0.9em;
}


/* -----------------------------------------------------------------------
   8. Responsive video / playlist embed  (revised)
   -------------------------------------------------------------------- */
.video-placeholder{
    width: 92%;
    max-width: 900px;
    margin: 2rem auto;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.video-placeholder::before{
    content:"";
    display:block;
    padding-top:56.25%;   /* 16:9 ratio */
}
.video-placeholder .video_wrapper{
    position:absolute;
    inset:0;
    width:100%;
    height:100%;
    padding:0!important;
}
.video-placeholder iframe{
    position:absolute;
    inset:0;
    width:100%;
    height:100%;
    border:0;
    box-sizing:border-box;
}
/* ---------- CONTRAST FIX: focus ring colour -------------------------- */
.video-placeholder iframe:focus-visible{
    outline:3px solid #005fa3;
    outline-offset:2px;
}

/* Responsive iframe wrapper for video or Shiny apps ----------- */
.embed-container {
  position: relative;
  height: 0;
  padding-bottom: 56.25%;   /* 16:9; change to 75% for 4:3, etc. */
  overflow: hidden;
  max-width: 100%;
}

.embed-container iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}


/* stronger drop shadow on dark-mode */
@media (prefers-color-scheme: dark) {
    .video-placeholder {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    }
}
