/* Mobile-first responsive design */

/* Portrait Phone Mode (< 768px width) */
@media (max-width: 767px) and (orientation: portrait) {
  :root {
    --header-height: 50px;
  }
  
  /* Navbar - minimal items only */
  .navbar {
    padding: 5px 10px !important;
    width: 100% !important;
  }
  
  /* Logo - hide text, show only home icon */
  .nav-brand span {
    font-size: 0 !important;
  }
  
  .nav-brand::before {
    content: "";
    display: inline-block;
    width: 24px;
    height: 24px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="%23ffffff"><path stroke-linecap="round" stroke-linejoin="round" d="m2.25 12 8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" /></svg>');
    background-size: contain;
    background-repeat: no-repeat;
  }
  
  .nav-brand small {
    display: none;
  }
  
  /* Create Now -> New */
  .nav-links button {
    padding: 8px 12px !important;
    font-size: 0 !important;
  }
  
  .nav-links button::after {
    content: "New";
    font-size: 14px;
    font-weight: bold;
  }
  
  /* Login/Profile button - show user icon or first letter */
  #login-button, #profile-button {
    padding: 8px !important;
    font-size: 0 !important;
    width: 36px;
    height: 36px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
  
  #login-button::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="white"><path stroke-linecap="round" stroke-linejoin="round" d="M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" /></svg>');
    background-size: contain;
    font-size: 20px;
  }
  
  #profile-button span {
    display: none !important;
  }
  
  #profile-button img {
    margin: 0 !important;
  }
  
  #profile-button div {
    margin: 0 !important;
    font-size: 14px !important;
  }
  
  /* Extra nav - show only save cloud icon */
  #extra-nav {
    display: flex !important;
  }
  
  #upload-button, #download-button {
    display: none !important;
  }
  
  #save-button {
    padding: 8px !important;
    width: 36px;
  }
  
  #save-button svg {
    width: 20px;
    height: 20px;
  }
  
  /* Toolbar - fewer items */
  .toolbar {
    margin-top: 10px;
  }
  
  .toolbar > button {
    padding: 6px 10px;
    font-size: 12px;
    margin: 2px;
  }
  
  /* Cell toolbox - hide copy, up, down buttons */
  #toolbox button#copy,
  #toolbox button#up,
  #toolbox button#down {
    display: none !important;
  }
  
  /* Cell toolbox adjustments */
  #toolbox {
    padding: 4px 8px !important;
  }
  
  #preset-scroll {
    gap: 2px !important;
  }
  
  #preset-scroll > div {
    min-width: 32px !important;
    height: 32px !important;
  }
  
  #presets {
    font-size: 11px !important;
    padding: 4px 6px !important;
  }
  
  /* Content adjustments */
  .content {
    height: calc(100vh - var(--header-height, 50px) - 100px);
    padding: 10px;
  }
  
  #notebookTitle {
    font-size: 24px;
    width: 80%;
  }
  
  #notebookAuthor {
    font-size: 14px;
    width: 60%;
  }
}

/* Landscape Phone Mode (< 768px height) */
@media (max-height: 767px) and (orientation: landscape) {
  :root {
    --header-height: 45px;
  }
  
  .navbar {
    padding: 4px 15px;
  }
  
  .nav-brand {
    font-size: 16px;
  }
  
  .nav-brand .version {
    font-size: 0.3em;
  }
  
  .nav-links a {
    font-size: 13px;
  }
  
  a.button, button {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .toolbar > button {
    padding: 6px 15px;
    font-size: 14px;
  }
  
  .cell-math-toolbox {
    top: var(--header-height, 45px);
  }
  
  .group > button {
    padding: 6px 10px;
    font-size: 13px;
  }
  
  .content {
    height: calc(100vh - var(--header-height, 45px) - 90px);
  }
}

/* Fix login button height consistency */
#login-button, #profile-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  box-sizing: border-box;
  line-height: 1;
}

#profile-button img,
#profile-button div {
  flex-shrink: 0;
}