/* Everflow cross-device responsive layer
 * Loaded after site.css. All cross-device breakpoints live here so base
 * visual styles stay single-source and do not compete across files.
 */

html{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
  scroll-padding-top:88px;
}
body{
  min-height:100vh;
  min-height:100dvh;
  overflow-x:hidden;
}
a,button,input,textarea{-webkit-tap-highlight-color:transparent}
button,.icon-btn,.primary-link,.ghost-link,.small-btn,.checkin-tab{touch-action:manipulation}
:focus-visible{outline:3px solid color-mix(in srgb,var(--red) 45%,transparent);outline-offset:3px}
.wrap{width:min(1120px,calc(100% - clamp(28px,5vw,56px)))}
.topbar{padding-top:env(safe-area-inset-top)}
.nav{min-width:0}
.brand,.links,.section-head>*{min-width:0}
.countdown-panel h1{font-size:clamp(46px,5vw,64px)}
.page-head h1{font-size:clamp(40px,4.6vw,54px)}
.checkin-head h1{font-size:clamp(38px,4.2vw,48px)}
.focus-panel h2{font-size:clamp(30px,3.2vw,34px)}
.course-title,.post h3,.archive-item strong{overflow-wrap:anywhere}
.note-input{max-width:100%}
.footer{padding-bottom:calc(42px + env(safe-area-inset-bottom))}

/* Large desktop / wide laptop */
@media(min-width:1280px){
  .study-hero{gap:32px}
  .countdown-panel{padding:40px}
  .focus-panel{padding:34px}
  .subject-card{padding:22px}
}

/* Laptop and tablet landscape */
@media(max-width:1100px){
  .study-hero{grid-template-columns:minmax(0,1.2fr) minmax(280px,.8fr);gap:20px}
  .countdown-panel,.focus-panel{border-radius:28px}
  .countdown-panel{padding:30px}
  .focus-panel{padding:26px}
  .course-table{min-width:700px}
  .course-table th,.course-table td{padding:11px 12px}
}

/* Tablet portrait */
@media(max-width:900px){
  .study-hero{grid-template-columns:1fr}
  .focus-panel{min-height:260px}
  .progress-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .checkin-head{align-items:start}
  .course-table{min-width:680px}
  .about-box{grid-template-columns:150px 1fr;gap:26px}
}

/* Tablet navigation uses the compact menu without inheriting phone sizing. */
@media(min-width:761px) and (max-width:1040px){
  .topbar .links{display:none!important}
  .topbar .menu-btn{display:grid!important;margin-left:auto}
  .mobile-panel{position:fixed;inset:calc(70px + env(safe-area-inset-top)) 0 auto 0;z-index:45;max-height:calc(100dvh - 70px - env(safe-area-inset-top));overflow:auto;padding:10px 16px calc(18px + env(safe-area-inset-bottom));background:var(--paper);border-bottom:1px solid var(--line);box-shadow:0 18px 42px rgba(0,0,0,.10)}
  .mobile-panel.open{display:grid!important}
  .mobile-panel a{min-height:46px;display:flex;align-items:center;padding:10px;border-bottom:1px solid var(--line);border-radius:10px}
  body.menu-open{overflow:hidden}
}

/* Navigation switches to phone layout */
@media(max-width:760px){
  html{scroll-padding-top:calc(76px + env(safe-area-inset-top))}
  .wrap{width:calc(100% - 24px)}
  .nav{height:62px}
  .brand{font-size:18px;gap:9px}
  .brand small{display:none}
  .brand img{width:34px;height:34px;border-radius:9px}
  .links{display:none}
  .menu-btn{display:grid;margin-left:auto}
  .icon-btn{width:44px;height:44px}
  .mobile-panel{display:none;position:fixed;inset:calc(62px + env(safe-area-inset-top)) 0 auto 0;z-index:45;max-height:calc(100dvh - 62px - env(safe-area-inset-top));overflow:auto;padding:10px 12px calc(16px + env(safe-area-inset-bottom));background:var(--paper);border-bottom:1px solid var(--line);box-shadow:0 18px 42px rgba(0,0,0,.10)}
  .mobile-panel.open{display:grid}
  .mobile-panel a{min-height:46px;display:flex;align-items:center;border-radius:10px;padding:10px}
  .mobile-panel .icon-btn{margin-top:10px}
  body.menu-open{overflow:hidden}

  .study-hero{padding:30px 0 24px;gap:14px}
  .countdown-panel,.focus-panel{border-radius:22px;padding:20px}
  .countdown-panel h1{font-size:clamp(38px,11vw,46px);margin-top:10px}
  .countdown-panel>p{font-size:14px;line-height:1.65}
  .countdown{margin:22px 0 14px;gap:8px}
  .countdown-unit{border-radius:16px;padding:15px 8px}
  .countdown-unit strong{font-size:clamp(30px,9vw,36px)}
  .countdown-unit span{font-size:10px;letter-spacing:.08em}
  .focus-panel{min-height:0;gap:28px}
  .focus-panel p{line-height:1.6}
  .primary-link,.ghost-link{min-height:44px}

  .section{padding:20px 0 44px}
  .section-head{align-items:flex-start;flex-wrap:wrap;gap:8px 16px;margin-bottom:18px}
  .section h2{font-size:27px}
  .section-head>a{padding:5px 0}
  .progress-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .subject-card{border-radius:18px;padding:15px;min-width:0}
  .subject-code{width:36px;height:36px}
  .subject-number{font-size:25px}
  .subject-card h3{font-size:15px;line-height:1.4;overflow-wrap:anywhere}
  .sync-card{grid-template-columns:1fr;border-radius:20px;padding:18px;gap:12px}
  .post{grid-template-columns:1fr;gap:7px;padding:20px 0}
  .post .tag{justify-self:start}
  .post h3{font-size:20px;line-height:1.45}
  .grid{grid-template-columns:1fr}

  .page{padding:40px 0 66px}
  .page-head{margin-bottom:32px}
  .page-head h1{font-size:clamp(36px,10.5vw,43px)}
  .page-head p{font-size:16px;line-height:1.7}
  .article{max-width:100%}
  .article h2{font-size:25px;margin-top:38px}
  .article p,.article li{font-size:16px;line-height:1.9}
  .article blockquote{margin:24px 0;padding:16px 18px}
  .archive-item{grid-template-columns:76px minmax(0,1fr);gap:14px}
  .about-box{grid-template-columns:1fr;gap:20px;border-radius:22px;padding:20px}
  .about-mark{width:96px;border-radius:20px}

  .checkin-shell{padding:30px 0 62px}
  .checkin-head{grid-template-columns:1fr;align-items:start;gap:14px;margin-bottom:20px}
  .checkin-head h1{font-size:clamp(35px,10vw,42px)}
  .checkin-head p{font-size:14px;line-height:1.7}
  .checkin-head .ghost-link{justify-self:start}
  .overall-card{border-radius:21px;padding:18px;margin-bottom:12px}
  .overall-row{align-items:flex-start;flex-direction:column;gap:4px}
  .overall-row strong{font-size:20px}
  .big-progress{height:10px}
  .sync-line{line-height:1.65}
  .checkin-tabs{
    position:sticky;
    top:calc(62px + env(safe-area-inset-top));
    z-index:30;
    margin:0 -12px 12px;
    padding:9px 12px 10px;
    background:color-mix(in srgb,var(--paper) 94%,transparent);
    backdrop-filter:blur(16px);
    -webkit-backdrop-filter:blur(16px);
    border-bottom:1px solid color-mix(in srgb,var(--line) 75%,transparent);
    scroll-snap-type:x proximity;
  }
  .checkin-tab{min-height:42px;padding:8px 14px;scroll-snap-align:start}
  .checkin-toolbar{align-items:flex-start;flex-direction:column;gap:10px;margin-bottom:12px}
  .toolbar-actions{width:100%}
  .small-btn{min-height:42px}
  .course-table{min-width:650px}
  .course-table th,.course-table td{padding:10px;font-size:12px}
  .course-table th{font-size:10px}
  .footer-inner{display:flex;flex-direction:column;gap:4px}
  .evera-toast-stack{bottom:calc(16px + env(safe-area-inset-bottom))}
}

/* Phone: table becomes native-feeling course cards instead of horizontal scrolling */
@media(max-width:640px){
  .checkin-toolbar{align-items:stretch}
  .toolbar-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .small-btn{width:100%;padding-inline:10px}

  .course-table-wrap{border:0;border-radius:0;overflow:visible;background:transparent}
  .course-table{display:block;width:100%;min-width:0;border-collapse:separate}
  .course-table thead{display:none}
  .course-table tbody{display:grid;gap:10px}
  .course-table tr{
    display:grid;
    grid-template-columns:38px minmax(0,1fr) auto;
    grid-template-areas:
      "check title duration"
      "number title video"
      "note note note";
    gap:4px 10px;
    align-items:start;
    padding:14px;
    border:1px solid var(--line);
    border-radius:18px;
    background:var(--card);
    box-shadow:0 8px 26px rgba(17,18,23,.045);
  }
  .dark .course-table tr{box-shadow:none}
  .course-table tr.done{background:color-mix(in srgb,var(--green) 8%,var(--card));border-color:color-mix(in srgb,var(--green) 24%,var(--line))}
  .course-table td{display:block;width:auto!important;min-width:0;padding:0!important;border:0!important;font-size:13px}
  .course-table td:nth-child(1){grid-area:check;display:flex;align-items:flex-start;padding-top:1px!important}
  .course-table td:nth-child(2){grid-area:number;align-self:end;font-size:11px;color:var(--muted);line-height:1.3}
  .course-table td:nth-child(2)::before{content:"#";margin-right:2px;opacity:.65}
  .course-table td:nth-child(3){grid-area:title;padding-right:2px!important}
  .course-table td:nth-child(4){grid-area:duration;justify-self:end;color:var(--muted);font-size:11px;line-height:1.4;padding-top:2px!important}
  .course-table td:nth-child(5){grid-area:video;justify-self:end;align-self:end;font-size:12px;line-height:1.4}
  .course-table td:nth-child(6){grid-area:note;margin-top:8px}
  .course-title{display:block;font-size:14px;line-height:1.5;font-weight:760}
  .course-meta{font-size:10px;margin-top:4px}
  .course-link{display:inline-flex;align-items:center;min-height:28px}
  .check{width:24px;height:24px;flex:0 0 24px}
  .check:checked:after{left:7px;top:3px;width:6px;height:11px}
  .note-input{min-width:0;width:100%;min-height:40px;border:1px solid var(--line);background:var(--soft);padding:8px 10px;border-radius:10px}
  .note-input:focus{background:var(--paper);border-color:color-mix(in srgb,var(--red) 40%,var(--line))}
}

/* Standard phones, including iPhone mini / SE widths */
@media(max-width:480px){
  .wrap{width:calc(100% - 20px)}
  .eyebrow{font-size:10px;letter-spacing:.13em}
  .countdown{grid-template-columns:repeat(2,minmax(0,1fr))}
  .progress-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .subject-card{padding:13px}
  .subject-top{gap:8px}
  .subject-number{font-size:22px}
  .subject-code{width:32px;height:32px;border-radius:10px;font-size:11px}
  .subject-card h3{font-size:14px;margin-top:10px}
  .subject-card p{font-size:11px;line-height:1.5}
  .mini-progress{margin-top:12px}
  .sync-card p{font-size:12px}
  .checkin-tabs{margin-inline:-10px;padding-inline:10px}
  .checkin-tab{font-size:12px;padding-inline:13px}
  .overall-card{padding:16px}
  .course-table tr{grid-template-columns:34px minmax(0,1fr) auto;padding:12px;border-radius:16px;gap:4px 8px}
  .course-title{font-size:13px}
  .footer{font-size:12px}
}

/* Very narrow legacy phones */
@media(max-width:340px){
  .progress-grid{grid-template-columns:1fr}
  .countdown-unit strong{font-size:28px}
  .toolbar-actions{grid-template-columns:1fr}
  .course-table tr{grid-template-columns:32px minmax(0,1fr)}
  .course-table td:nth-child(4),.course-table td:nth-child(5){justify-self:start}
  .course-table tr{
    grid-template-areas:
      "check title"
      "number title"
      "duration video"
      "note note";
  }
}

/* Landscape phones: reduce vertical bulk */
@media(max-height:520px) and (orientation:landscape) and (max-width:900px){
  .study-hero{padding-top:20px}
  .focus-panel{min-height:0}
  .checkin-shell{padding-top:22px}
  .mobile-panel{max-height:calc(100dvh - 62px - env(safe-area-inset-top))}
}

/* Hover effects only on devices that really have hover */
@media(hover:hover) and (pointer:fine){
  .subject-card,.card,.overall-card,.course-table tr{transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease}
  .subject-card:hover,.card:hover{transform:translateY(-2px);border-color:color-mix(in srgb,var(--muted) 25%,var(--line));box-shadow:0 12px 34px rgba(17,18,23,.06)}
  .primary-link:hover{filter:brightness(.96)}
}

@media(prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
}
