/* =========================================================
   OSID Model Entity Page  —  osid-entity.css
   Supplement to osid-models.css
   ========================================================= */

/* ---------------------------------------------------------
   Back link — below site header, above title band
   --------------------------------------------------------- */

/* title-nav: stacks back/forward links in the title band */
.title-nav {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    margin-left: auto;
    margin-top: -1.25rem;
    align-self: flex-start;
    padding: 0 var(--row-h) 0 0;
}

.back-link,
.forward-link {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-family: 'Urbanist', var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--t3);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--t-ui) var(--ease);
}

/* standalone (TOC pages): keep original positioning */
.title-band > .back-link,
.title-band > .forward-link {
    margin-left: auto;
    margin-top: -1.25rem;
    align-self: flex-start;
    padding: 0 var(--row-h) 0 0;
}

.back-link:hover,
.forward-link:hover {
    color: var(--accent);
}

.back-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0.25rem 0.375rem 0.25rem 0;
    border-color: transparent currentColor transparent transparent;
}

.forward-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0.25rem 0 0.25rem 0.375rem;
    border-color: transparent transparent transparent currentColor;
}

.forward-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0.25rem 0 0.25rem 0.375rem;
    border-color: transparent transparent transparent currentColor;
}


/* ---------------------------------------------------------
   Title band — transparent spacer on entity pages
   --------------------------------------------------------- */

div.title-logo {
    width: 7rem;
    height: 5rem;
    flex-shrink: 0;
}


/* ---------------------------------------------------------
   Package description
   --------------------------------------------------------- */

.package-desc {
    padding: 1.25rem var(--row-h) 0 var(--row-h);
    margin-right: 6rem;
    font-size: .9rem;
}

.package-desc h2 {
    margin-top: 1.25rem;
    font-size: 1rem;
}

.package-desc h3 {
    font-family: 'Urbanist', var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--t1);
    margin-top: 1.5rem;
    margin-bottom: 0.375rem;
}

.package-desc p + p,
.package-desc h2 + p,
.package-desc h3 + p {
    margin-top: 0.75rem;
}

.package-desc ul {
    margin-top: 0.625rem;
    margin-left: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.7;
}

.package-desc code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--t-name);
    background: none;
    border: none;
    padding: 0;
}

.desc-more-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.desc-more-wrap.open {
    grid-template-rows: 1fr;
}

.desc-more-inner {
    overflow: hidden;
}

.desc-more-btn {
    display: inline-block;
    margin-top: 0.625rem;
    font-family: 'Urbanist', var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.01em;
}

.desc-more-btn:hover {
    text-decoration: underline;
}


/* ---------------------------------------------------------
   Entity list
   --------------------------------------------------------- */

.entity-list {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.entity-section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 2px 10px rgba(0, 0, 0, 0.03);
}


/* ---------------------------------------------------------
   Entity header row
   --------------------------------------------------------- */

.entity-header {
    display: flex;
    align-items: flex-start;
}

.entity-toggle {
    width: var(--col-toggle);
    min-width: var(--col-toggle);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    position: relative;
    border-right: 1px solid var(--line);
    background: var(--surface-th);
}

.expandable .entity-toggle:hover {
    background: var(--accent-bg);
    cursor: pointer;
}

.entity-toggle .toggle {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.entity-toggle .toggle-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.entity-toggle .toggle:checked ~ .toggle-label .chevron {
    transform: rotate(90deg);
    border-left-color: var(--accent);
}

.entity-toggle .toggle-label:hover .chevron {
    border-left-color: var(--accent);
}

.entity-meta {
    flex: 1;
    padding: 1rem 1.25rem;
}

.entity-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.375rem;
    justify-content: space-between;
}

.entity-badges {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-left: auto;
    padding-left: 1rem;
}

.entity-name {
    font-family: 'Urbanist', var(--font);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--t-name);
    letter-spacing: -0.01em;
    margin-right: 0.25rem;
}

.inherits-badge {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: var(--t-code);
    background: var(--surface-d1);
    border: 1px solid #a8c4d8;
    border-radius: 1rem;
    padding: 0.125rem 0.625rem;
    white-space: nowrap;
}

.behavior-badge {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: #2a6648;
    background: var(--surface-d2);
    border: 1px solid #8ec4a4;
    border-radius: 1rem;
    padding: 0.125rem 0.625rem;
    white-space: nowrap;
}

.entity-desc {
    font-size: 0.875rem;
    color: var(--t2);
    line-height: 1.6;
}

.entity-desc code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--t-code);
}


/* ---------------------------------------------------------
   Entity body
   --------------------------------------------------------- */

.entity-body {
    padding: 1.25rem 6rem 1.25rem 6rem;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.entity-body p {
    font-size: 0.875rem;
    color: var(--t2);
    line-height: 1.7;
    max-width: 72ch;
}

.entity-body p + p {
    margin-top: 0.875rem;
}

.entity-body h2 {
    font-family: 'Urbanist', var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--t1);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 1.25rem 0 0.375rem;
}

.entity-body code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--t-code);
}

.entity-body pre,
.package-desc pre {
    background: var(--surface-th);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    overflow-x: auto;
    margin-top: 0.5rem;
}

.entity-body pre code,
.package-desc pre code {
    color: var(--t1);
}


/* ---------------------------------------------------------
   Main expand / collapse
   --------------------------------------------------------- */

.expand-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.expand-inner {
    overflow: hidden;
}

.entity-section.expandable:has(.entity-toggle .toggle:checked) > .expand-wrap {
    grid-template-rows: 1fr;
}


/* ---------------------------------------------------------
   Inherited attributes collapsible
   --------------------------------------------------------- */

.inherited-section {
    border-top: 1px solid var(--line);
}

.inherited-toggle-row {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    background: var(--surface-d2);
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.inherited-toggle {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.inherited-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.4rem var(--row-h);
    cursor: pointer;
    width: 100%;
    user-select: none;
}

.inherited-toggle-label:hover {
    background: var(--surface-d4);
}

.inh-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0.2rem 0 0.2rem 0.3rem;
    border-color: transparent transparent transparent var(--bar-2);
    transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.inherited-toggle:checked ~ .inherited-toggle-label .inh-chevron {
    transform: rotate(90deg);
    border-left-color: var(--accent);
}

.inherited-label {
    font-family: 'Urbanist', var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: #2a6648;
    text-transform: uppercase;
}

.inherited-expand-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 450ms cubic-bezier(0.4, 0, 0.2, 1);
}

.inherited-section:has(.inherited-toggle:checked) .inherited-expand-wrap {
    grid-template-rows: 1fr;
}


/* ---------------------------------------------------------
   Elements tables
   --------------------------------------------------------- */

.entity-elements {
    border-top: 1px solid var(--line);
}

.elements-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 1rem;
}

.elements-head th {
    background: var(--surface-d1);
    border-bottom: 1px solid var(--line);
    padding: 0.375rem var(--row-h);
    text-align: left;
    font-family: 'Urbanist', var(--font);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--t3);
}

.el-name   { width: 14rem; }
.el-syntax { width: 8rem; }
.el-many   { width: 3.5rem; text-align: center; vertical-align: top; }

.many-sym {
    font-size: 3rem;
    color: var(--accent);
    display: block;
    line-height: 1;
    margin-top: -0.3em;
}

.el-desc   { width: auto; }

.element-row td {
    padding: 0.5rem var(--row-h);
    border-bottom: 1px solid var(--line);
    font-size: 0.875rem;
    color: var(--t2);
    background: var(--surface);
    vertical-align: top;
}

.element-row:last-child td {
    border-bottom: none;
}

.inherited-row td {
    color: var(--t2);
    background: #f8fcf9;
}

.inherited-row:nth-child(even) td {
    background: #f8fcf9;
}

.inherited-group-header td {
    background: var(--surface-d2) !important;
    border-bottom: 1px solid var(--line);
    padding: 0.25rem var(--row-h);
}

.inherited-group-label {
    font-family: 'Urbanist', var(--font);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #2a6648;
}

.el-name code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--t-name);
    background: none;
    border: none;
    padding: 0;
}

.syntax-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--t-code);
    background: #ddeaf4;
    border: 1px solid #a8c4d8;
    border-radius: 3px;
    padding: 0.0625rem 0.375rem;
    white-space: nowrap;
    margin-top: -.35rem;
}

.el-desc code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--t-code);
}


/* ---------------------------------------------------------
   Linked syntax tags
   --------------------------------------------------------- */

a.syntax-tag {
    text-decoration: none;
    cursor: pointer;
    transition: background var(--t-ui) var(--ease), border-color var(--t-ui) var(--ease);
}

a.syntax-entity-link {
    color: var(--accent);
    background: #d8f0ec;
    border-color: #6abcaa;
}

a.syntax-entity-link:hover {
    background: #b8e4dc;
    border-color: var(--accent);
}

a.syntax-prim-link {
    color: var(--t-code);
    background: #ddeaf4;
    border-color: #a8c4d8;
}

a.syntax-prim-link:hover {
    background: #c8ddf0;
    border-color: var(--t-code);
}
