/*
 * The app's frame (layouts/application.html.erb): a header with the logo,
 * the nav, the "Nesta página" menu and the preferences; the page column with
 * the "Nesta página" sidebar on wide screens; the footer. On phones the nav
 * becomes a tab bar at the bottom of the screen.
 */

/* The page is at least as tall as the screen and the content grows, so the
   footer stays at the bottom of short pages. */
body.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body.app > .shell { flex: 1 0 auto; width: 100%; }

.app {
  .gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

  /* Header */
  .app-header { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
  .app-header .bar { max-width: 1260px; margin: 0 auto; display: flex; align-items: center; gap: 22px; padding-block: 10px; }
  .app-logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--ink); font-family: var(--serif); font-variation-settings: var(--axes); }
  .app-logo:hover { text-decoration: none; }
  .app-logo svg { width: 26px; height: 26px; }
  .app-nav { display: flex; gap: 4px; }
  .app-nav a { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 600; font-size: 14px; position: relative; }
  .app-nav a:hover { background: var(--soft-bg); color: var(--ink); text-decoration: none; }
  .app-nav a[aria-current="page"] { color: var(--ink); }
  .app-nav a[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -11px; height: 2px; border-radius: 2px; background: var(--accent); }
  /* Amigos with its caret: the caret opens Amigos and Grupos, pointing up while open */
  .nav-split { display: flex; align-items: center; }
  .nav-more { position: relative; }
  .nav-more > summary { list-style: none; cursor: pointer; display: grid; place-items: center; width: 22px; height: 30px; margin-left: -6px; border-radius: var(--radius-sm); color: var(--muted); }
  .nav-more > summary::-webkit-details-marker { display: none; }
  .nav-more > summary:hover { background: var(--soft-bg); color: var(--ink); }
  .nav-more > summary svg.icon { width: 14px; height: 14px; transition: transform .2s; }
  .nav-more[open] > summary svg.icon { transform: rotate(180deg); }
  .nav-more .panel { position: absolute; left: -60px; top: calc(100% + 10px); z-index: 30; min-width: 170px; display: grid; padding: 6px; background: var(--paper); border-radius: var(--radius-sm);
    box-shadow: 0 0 0 1px var(--line), 0 16px 40px -18px rgba(0, 0, 0, .45); }
  .app-nav .nav-more .panel a { display: block; padding: 8px 10px; font-size: 14px; color: var(--ink); }
  .app-nav .nav-more .panel a[aria-current="page"] { color: var(--accent); }
  .app-nav .nav-more .panel a[aria-current="page"]::after { content: none; }

  /* The bell, beside the preferences: a round button with the unread count on
     its corner, and the latest notifications in a dropdown below it. */
  .notifications-menu { position: relative; }
  .notifications-menu > summary { position: relative; }
  .notifications-menu > summary[aria-current="page"] { box-shadow: inset 0 0 0 2px var(--accent); }
  .notifications-menu > summary .count { position: absolute; top: -5px; right: -7px; box-shadow: 0 0 0 2px var(--paper); }
  .notifications-menu .panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(380px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow-y: auto;
    background: var(--paper); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line), 0 18px 40px -20px rgba(0, 0, 0, .45); padding: 14px 16px; }
  .notifications-menu .menu-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
  .notifications-menu .all { font-size: 13px; font-weight: 600; }
  .notifications-menu .empty-menu { color: var(--muted); font-size: 14px; margin: 6px 0; }
  .notifications-menu li.notification { padding: 10px 0; font-size: 14px; }
  .header-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
  /* The profile: the person's round picture, last in the header */
  .profile-link { display: inline-flex; border-radius: 50%; }
  .profile-link .avatar { width: 34px; height: 34px; font-size: 14px; }
  .profile-link:hover .avatar, .profile-link[aria-current="page"] .avatar { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
  .header-end .button_to { margin: 0; display: inline-flex; }

  /* Round icon buttons in the header (the menus' summaries) */
  .preferences-menu > summary, .toc-menu > summary, .notifications-menu > summary { width: 34px; height: 34px; }

  @media (max-width: 760px) {
    .app-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--paper); border-top: 1px solid var(--line); justify-content: space-around;
      padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
    .app-nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 4px 8px; }
    /* In the bottom bar the menu opens upwards: the caret points up, and down while open */
    .nav-more > summary { width: 20px; height: 40px; margin-left: -10px; }
    .nav-more > summary svg.icon { transform: rotate(180deg); }
    .nav-more[open] > summary svg.icon { transform: none; }
    .nav-more .panel { top: auto; bottom: calc(100% + 14px); left: auto; right: -8px; }
    .app-nav .nav-more .panel a { padding: 12px 14px; font-size: 15px; }
    .app-nav a svg.icon { width: 20px; height: 20px; }
    .app-nav a[aria-current="page"]::after { bottom: auto; top: -7px; }
    /* The bell isn't at the screen's edge: its dropdown spans the screen instead. */
    .notifications-menu .panel { position: fixed; left: 16px; right: 16px; width: auto; top: calc(62px + env(safe-area-inset-top, 0px)); max-height: calc(100vh - 160px); }
  }

  /* Page column and the "Nesta página" sidebar */
  .shell { max-width: 1260px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 960px); justify-content: center; gap: 40px; }
  .shell.with-toc { grid-template-columns: minmax(0, 960px) 220px; }
  .page { min-width: 0; padding-block: 28px 64px; display: grid; gap: 22px; align-content: start; }
  .page.narrow { max-width: 460px; width: 100%; margin: 0 auto; }
  .page.medium { max-width: 720px; width: 100%; margin: 0 auto; }
  @media (max-width: 1100px) { .shell.with-toc { grid-template-columns: minmax(0, 960px); } .toc { display: none !important; } }

  .toc { position: sticky; top: calc(84px + env(safe-area-inset-top, 0px)); align-self: start; margin-top: 28px; max-height: calc(100vh - 120px); overflow-y: auto; }
  .toc-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
  .toc-list { position: relative; border-left: 2px solid var(--line); }
  .toc-list ul { list-style: none; margin: 0; padding: 0; display: block; }
  .toc-link { display: block; width: 100%; text-align: left; background: none; border: 0; box-shadow: none; cursor: pointer; padding: 6px 0 6px 14px; color: var(--muted); font: inherit;
    font-size: 13px; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .2s; }
  .toc-link:hover { color: var(--ink); background: none; }
  .toc-link[aria-current="true"] { color: var(--accent); }
  .toc-marker { position: absolute; left: -2px; width: 2px; border-radius: 2px; background: var(--accent); transition: top .3s cubic-bezier(.3, 1.3, .5, 1), height .3s; }
  .toc-top { margin-top: 14px; font: inherit; font-size: 12px; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
  .toc-top:hover { color: var(--ink); }

  /* The same links in a header dropdown below 1100px */
  .toc-menu { position: relative; display: none; }
  .toc-menu > summary, .notifications-menu > summary { list-style: none; cursor: pointer; display: grid; place-items: center; border-radius: 50%; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
  .toc-menu > summary::-webkit-details-marker, .notifications-menu > summary::-webkit-details-marker { display: none; }
  .toc-menu > summary svg.icon, .notifications-menu > summary svg.icon { width: 18px; height: 18px; }
  .toc-menu .panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(260px, calc(100vw - 32px)); background: var(--paper); border-radius: var(--radius);
    box-shadow: 0 0 0 1px var(--line), 0 16px 40px -18px rgba(0, 0, 0, .45); padding: 12px 14px; }
  @media (max-width: 1100px) { .toc-menu.has-items { display: block; } }
  [data-toc-section] { scroll-margin-top: 80px; }

  /* Footer */
  .app-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 40px; }
  .app-footer a { color: var(--muted); }
  /* Phones: room for the tab bar below the footer, the page's last line. */
  @media (max-width: 760px) { .app-footer { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); } }

  @media (prefers-reduced-motion: reduce) { .toc-marker { transition: none; } }
}
